Nov 22, 2009

Php Date() Problem [resolved] - date() seems to loop same ninute.

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > PHP Programming

Php Date() Problem [resolved] - date() seems to loop same ninute.

sonesay
My setup is a macbook pro and I have apache+ mysql + php already included I think.

the php is version 4.4.4

I have been using the date() to store dates into my mysql tables in the past and it worked corectly. I dont know what could of happen but now the date() function is returning an incorrect time.

I made a test script test.php

CODE
<?php

$date_time = date('y-m-d H:m:s');
echo($date_time);

?>


and loaded it up. My laptops system time would be 1.35.33 PM

and the date and time returned from php would be 07-06-28 13:06:56

I would hit refresh on the browser but it would still loop in that same minute
e.g.
QUOTE
07-06-28 13:06:56
07-06-28 13:06:57
07-06-28 13:06:58
07-06-28 13:06:59
07-06-28 13:06:00
07-06-28 13:06:01

.........

Any ideas on how I could fix this problem? would I just be better too to upgrade to lastest version of php and hopefully it will not have that problem.

 

 

 


Comment/Reply (w/o sign-up)

BuffaloHELP
It seems like your PHP.ini isn't set to the correct timezone? It's about 30 minutes off.

Open PHP.ini and search
QUOTE
[Date][br];Defines the default timezone used by the date functions[/br]
;date.timezone =


and set to the correct timezone. And see if it matches up. Don't forget to remove ";" to be active.

And just in case you were wondering, 13:00 is 1pm in military or 24 hour style. Just pick another time variable to show it as 1:00

Comment/Reply (w/o sign-up)

sonesay
thanks for info on changing the time zones. there is the other problem with it was it keep repeating the same minute.

QUOTE
07-06-28 13:06:56
07-06-28 13:06:57
07-06-28 13:06:58
07-06-28 13:06:59
07-06-28 13:06:00
07-06-28 13:06:01



I noticed that after an hour it would change to
07-06-28 14:06:01 so always stuck on that 6min into the hour. I went a head and tried to download and install php 5 but not very fimilar to mac os x so I googled and found this website. http://www.entropy.ch/software/macosx/php/ downloaded the file PHP 5.2.2 for Apache 1.3 and unzipped and ran it. the installation fails and now apache dont work :E. Right now im trying to get apache back to work so if any mac users fimilar with this problem please help.

Comment/Reply (w/o sign-up)

jlhaslip
I think XAMPP is available as a one-click installer for Apache, Mysql and php for OSX. search:XAMPP for the download page and to check whether it will run on your machine.

Comment/Reply (w/o sign-up)

sonesay
Thanks XAMMP is very easy to install, now I can get back to building my site ^^

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : php, date, problem, date, loop, ninute,

  1. Php Date()?
    timezone is offset (4)
  2. Displaying Date And Time (gmt+8)
    (5)
    how to display date and time (gmt+8)? any help would be appreciated.....
  3. Display The Current Date/time
    With a simple PHP code (4)
    Use this code to display the current date and time. CODE   $date = date('l dS \of F Y
    h:i:s A');   echo "$date"; ?> "l" would display the current day of the week such as
    Sunday. d displays the day of the month... such as 1 and S adds the appropriate suffix(st). /of
    simply displays the word "of". F displays the current month with no abbreviations while Y displays
    the four digit year(2007). "h" displays the current hour with leading zeros if necessary(Ex. 06 for
    6 o'clock). "i" displays the minute of the hour with leading zeros if necessary. ....
  4. Help Needed With Directory/file Listing Code Infinite Loop
    Made an infinite loop but why is this so? (5)
    Hi all ive got a small and simple (for the moment atleast /unsure.gif"
    style="vertical-align:middle" emoid=":unsure:" border="0" alt="unsure.gif" /> )file and directory
    listing script in php as follows CODE $dir = "."; $num = 0; $file = scandir($dir); while($file
    = scandir($dir)){     echo $file ;     echo " ";     $num = $num + 1;      }; the concept is
    simple enough, the directory to start with is the current one, so scan this directory and while we
    have a result do a loop to echo the file/directories found, incriment the array number by one so we
    get the....
  5. Simple Php Calendar And Yahoo! Calendar Connection
    linking each date to Yahoo! calendar (7)
    Original simple PHP calendar source here I was looking for a simple PHP generated calendar. But I
    wanted to place detailed information to show on demand. And installing another database with
    separate management would have been too much of access codes and passwords to remember. And what if
    I want someone else to manage the calendar when I am not able? This is my version of using simple
    PHP calendar script to link to Yahoo! calendar. The twist is that figuring out how Yahoo! calendar
    selection worked. And then depending on which date was clicked it will bring up the a....
  6. For Loop
    for loop problem (5)
    i'd like to make for loop which dependes on a $_GET variable: here is my tries: CODE if
    (isset($_GET ) { switch($_GET )     {         case 'asc': $exp1 = "$x>0"; $exp2 =
    "$x=$total";             $condition = '$x++';             break;         case
    'desc'; $exp1 = "$x=$total"; $exp2 = "$x>0";             $condition = '$x--';
                break;     } } then CODE for($exp1; $exp2; $condition) { //** do something
    **// } that is what i want to do, sure this code is wrong so what is the valid code?!!....
  7. Adding One Day To Date
    i'd like to add one day to date (9)
    I would like to add one day to date.Doesn't any one have a simple code that I can have. or mabe
    a link. date("Y-m-d H:i:s") + (1800 * 24);//this doesnt work ;/ but i need to have 24 hours after
    date for a check. Thanks for taking the time i hope some one can help me out. Dont warry about it
    if you dont have some thing already made. ....
  8. For Each Loop Help
    (1)
    I have a page where I list a number of records from my db. Under each record I have a checkbox and a
    text field. At the bottom of the list I have a submit button. I want to be able to check various
    boxes and edit the text field then click the button to update all of the records. I currenlty have
    the following and it updates the records ok (checkbox, I haven't messed with the text field yet)
    when I first check the boxes but it will not update the db when I uncheck the boxes. My form: PHP
    Code: CODE if(isset($_POST )); $active1=serialize($_POST );....
  9. Loop Through Form
    How do you do it? (9)
    In ASP you'd do this: CODE For Each Field in Request.Form So how do you do it in PHP? I
    want to loop through a form, check to see if it has a value and if so, append to a string to send as
    the body of my email.....
  10. Phpbb V2.0.16 Has Been Released
    Release Date 06/27/05 (4)
    QUOTE phpBB Group announces the release of phpBB 2.0.16. This release addresses some bugfixes
    and one critical security issue. http://www.phpbb.com/phpBB/viewtopic.php?f=14&t=302011 ....
  11. While Loop
    how to stop the timeout (9)
    I have written a piece of code that is to make a forum which contains a table consiting of two
    colums and a determind number of rows with a while loop, however when I test the page it goes and
    goes, and then returns an error stating that the maximum 30 second limit has been reached, I
    understand what that means I just don't know why it's looping forever: CODE while
    ($weightnum > 0); { echo " ";    echo   ' ';    echo   ' ';    echo " ";
    $appendval = $apendval + 1; $weightnum = $weightnum - 1; } Also Am I appending a number t....
  12. Question About The Date() Function In Php
    (4)
    Hi this is the code I've been using. This works perfectly fine with mysql but I'm having
    trouble with getting the exact time. It probably has something to do with time zones and countries.
    Is there something that I need to set to get the time right? I'm from the Philippines and we
    have the same time as Singapore and HongKong. Help please. Tnx. /huh.gif' border='0'
    style='vertical-align:middle' alt='huh.gif' /> CODE $date = date('H:i A, jS F Y');
    ....

    1. Looking for php, date, problem, date, loop, ninute,

Searching Video's for php, date, problem, date, loop, ninute,
See Also,
advertisement


Php Date() Problem [resolved] - date() seems to loop same ninute.

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com