Jump to content

date format issue, says 1970 always :(


wmguk

Recommended Posts

Hey,

 

I am trying to format a date, its not a timestamp, basically you select the day, month and year from a drop down and its put in to the database in 3 seperate fields..

 

so if i do

$datef = "$date_day"."$date_month"."$date_year" ;

then echo $datef it displays right (17082007)

 

now i try and format the output, and its wrong..

$date = date("jS F Y", $datef);

 

i get 17th February 1970

 

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/96486-date-format-issue-says-1970-always/
Share on other sites

date() wants a UNIX timestamp, which is the number of seconds since January 1, 1970. You can use mktime() to make a UNIX timestamp using the day, month, and year (and minutes, seconds, and hours if you want). This is how you use it:

 

$date = date("jS F Y", mktime(0, 0, 0, $date_month, $date_day, $date_year));

 

The three zeros at the beginning are the hours, minutes, and seconds.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.