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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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