This is a discussion on Weird results for 2 lines of damn code within the PHP General forums, part of the PHP Programming Forums category; Hi everyone, This "very simple" program is driving me nuts, heres what i am doing: 1.making a ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi everyone,
This "very simple" program is driving me nuts, heres what i am doing: 1.making a timestamp with the current time. 2.reading from the timestamp and trying to "render" the date again $ryan=strtotime ("now"); echo $ryan."<br>"; echo strftime( "%G-%m-%a %H:%M:%S", $ryan)."<br>"; This is the result: -10-Fri 02:29:33 the month part,friday part and the time is correct....why no year? Where am i going wrong? Cheers, -Ryan |
|
|||
|
Replace %G _with_ %Y
-- Jon Kriek http://phpfreaks.com "Ryan A" <ryan@coinpass.com> wrote in message news:00ef01c3944b$9d078680$f081aa51@l2zcaxu7emppqh ... > Hi everyone, > This "very simple" program is driving me nuts, heres what i am doing: > 1.making a timestamp with the current time. > 2.reading from the timestamp and trying to "render" the date again > > $ryan=strtotime ("now"); echo $ryan."<br>"; > echo strftime( "%G-%m-%a %H:%M:%S", $ryan)."<br>"; > > This is the result: > -10-Fri 02:29:33 > > the month part,friday part and the time is correct....why no year? > Where am i going wrong? > > Cheers, > -Ryan |
|
|||
|
* Thus wrote Ryan A (ryan@coinpass.com):
> Hi everyone, > This "very simple" program is driving me nuts, heres what i am doing: > 1.making a timestamp with the current time. > 2.reading from the timestamp and trying to "render" the date again > > $ryan=strtotime ("now"); echo $ryan."<br>"; > echo strftime( "%G-%m-%a %H:%M:%S", $ryan)."<br>"; You don't want to use %G for the year, there are cases where the year will be wrong if you are using it with %m %a. See the example 2 in strftime http://php.net/strftime use %Y instead. Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ |