Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getdate problems

Status
Not open for further replies.

peasepud

Programmer
Jul 20, 2007
35
0
0
Hi,

Im taking a date from a database and storing it in $when which on echo is returning the expected value of 2007-08-01 19:45:00

if I then take $when and process it through getdate($when) and print_r the array I get:

Array ( [seconds] => 21 [minutes] => 1 [hours] => 15 [mday] => 23 [wday] => 2 [mon] => 10 [year] => 2007 [yday] => 295 [weekday] => Tuesday [month] => October [0] => 1193148081 )

Can anyone tell me where Im going wrong? I seem to have added on about 90 days or so somewhere?

 
php.net said:
getdate

(PHP 4, PHP 5)

getdate — Get date/time information
Description
array getdate ( [int $timestamp] )

Returns an associative array containing the date information of the timestamp, or the current local time if no timestamp is given.
Parameters
[red]
timestamp

The optional timestamp parameter is an [blue]integer[/blue] Unix timestamp that defaults to the current local time if a timestamp is not given. In other words, it defaults to the value of time().
[/red]

getdate expects a unix timestamp, i the form of an integer.
Your Date value isn't in that format.

Try running your $when variable through the strtotime() function, and then through getdate.






----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
as vacunita implies, it won't work the way that you have it. try

Code:
print_r(getDate(strtotime($when)));
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top