Forum Moderators: coopster

Message Too Old, No Replies

How to turn date in epoch timestamp back to date parts?

         

tresmom5

1:54 pm on Oct 9, 2004 (gmt 0)

10+ Year Member



I've got turning dates into epoch timestamps figured out, but how do you turn them back to date parts?
Say you got something that calculates $birthday. Ok, now $birthday is in an epoch timestamp. Now how do you take $birthday and turn it back into dateparts?

Hope that makes sense.

mincklerstraat

2:02 pm on Oct 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll need to use date() [be2.php.net]. The first parameter is a string corresponding to the formatting style you want - like 3:04 PM - Wednesday, October 15, 1978 or 10-15-80. You have a whole bunch of options, with letters in that string corresponding to the hour, minute, abbreviated day of week, non-abbreviated day of week, etc. In between these letters you can put punctuation or spaces to get the format you want. Second parameter is that unix timestamp you've made.

tresmom5

2:54 pm on Oct 9, 2004 (gmt 0)

10+ Year Member



Ok, still a little confused.

I tried this

$birthday = date("M, d, Y");
echo $birthday;

but it echos today's date.

How do I get it to echo $birthday in date format and not today's date?

Teresa

eggy ricardo

3:04 pm on Oct 9, 2004 (gmt 0)

10+ Year Member



$birthday = date('M, d, Y', $birthday);

That should work where $birthday is your timestamp. If this is left off it just uses todays date.

Hope this helps

Cheers
Richard

tresmom5

3:13 pm on Oct 9, 2004 (gmt 0)

10+ Year Member



Thank you! Thank you! Thank you! Would you believe I stayed up till 2 am trying to figure this out. I really try to figure things out on my own because I learn a lot from my mistakes, but you probably saved me three more days of trying to figure it out on my own, lol.

Teresa

eggy ricardo

3:16 pm on Oct 9, 2004 (gmt 0)

10+ Year Member



Glad to be of assistance. Despite not knowing a great deal of php, i am currently doing a fairly big project with a lot of date handling involved so that one was fresh in my mind.

Cheers
Richard