Weird results for 2 lines of damn code

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-17-2003
Ryan A
 
Posts: n/a
Default Weird results for 2 lines of damn code

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
Reply With Quote
  #2 (permalink)  
Old 10-17-2003
Jon Kriek
 
Posts: n/a
Default Re: Weird results for 2 lines of damn code

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

Reply With Quote
  #3 (permalink)  
Old 10-17-2003
Curt Zirzow
 
Posts: n/a
Default Re: [PHP] Weird results for 2 lines of damn code

* 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/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:49 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0