HyderA
HyderA

Reputation: 21401

PHP simple date question

Function

echo date( "m/d/Y h:i a", "10/22/2009 12:32 am" );

Output

12/31/1969 07:00 pm 

Why is my output not giving me the correct date, what am I doing wrong?

Upvotes: 0

Views: 217

Answers (3)

jochil
jochil

Reputation: 1074

How you can read in the PHP Documentation for the date function the second parameter must be an unix timestamp. You can use the mktime Function to convert your date into a timestamp.

Upvotes: 1

Palantir
Palantir

Reputation: 24182

echo date( "m/d/Y h:i a", strtotime("10/22/2009 12:32 am" ));

Upvotes: 7

mfabish
mfabish

Reputation: 190

The second argument should be a timestamp, not a date string.

Upvotes: 3

Related Questions