Converting seconds since the Unix epoch to RFC 2822 format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
starsol
Forum Newbie
Posts: 24
Joined: Thu Jul 31, 2003 8:30 am
Location: Norfolk, England.
Contact:

Converting seconds since the Unix epoch to RFC 2822 format

Post 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?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

date()
echo date("r");
starsol
Forum Newbie
Posts: 24
Joined: Thu Jul 31, 2003 8:30 am
Location: Norfolk, England.
Contact:

Post 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).
starsol
Forum Newbie
Posts: 24
Joined: Thu Jul 31, 2003 8:30 am
Location: Norfolk, England.
Contact:

Post by starsol »

Found solution: I just needed to add the time to the date function.

Code: Select all

date('r', 1116329331)
Post Reply