Page 1 of 1

Converting seconds since the Unix epoch to RFC 2822 format

Posted: Tue May 17, 2005 6:44 am
by starsol
I would imagine this is pretty easy, but I must be overlooking something in the manual as I just can't seem to figure out how to do it. Can anyone give me a hint?

Posted: Tue May 17, 2005 7:16 am
by anjanesh
date()
echo date("r");

Posted: Tue May 17, 2005 7:34 am
by starsol
Thanks anjanesh, but I think you have misunderstood what I'm trying to do.

Code: Select all

echo date("r");
as you pointed out provides the RFC 2822 formatted date for now. What I want to do is take the time in seconds since the Unix epoch, then convert it to RFC 2822.

For example, an article in my database was first created at 1116329331 seconds since the Unix epoch. I am trying to create a function that takes that number, and converts it into something like Tue, 17 May 2005 13:34:07 +0000 (thats not the actual time it converts into, just an example).

Posted: Tue May 17, 2005 7:41 am
by starsol
Found solution: I just needed to add the time to the date function.

Code: Select all

date('r', 1116329331)