Time convertion

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
jonas89
Forum Newbie
Posts: 5
Joined: Thu Jan 12, 2012 4:28 pm

Time convertion

Post by jonas89 »

Hi, I am try to convert this : Thu, 12 Jan 2012 11:18:06 +0100 to something more neat and short like 12.01.2012 for my website. I tried doing some research, but I'm stuck. Help is much appreciated.
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: Time convertion

Post by Vegan »

I use

Code: Select all

date ("F d, Y (H:i:s)", getlastmod());
Now if you notice, I use a comma after the day to make the date more normal

you could use the period easy

Code: Select all

date("F.d.Y")
easy once you have the a couple of code snippets to look at
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Time convertion

Post by Christopher »

jonas89 wrote:Hi, I am try to convert this : Thu, 12 Jan 2012 11:18:06 +0100 to something more neat and short like 12.01.2012 for my website. I tried doing some research, but I'm stuck. Help is much appreciated.
Try:

Code: Select all

$timestamp = strtotime('Thu, 12 Jan 2012 11:18:06 +0100');
echo date('m.d.Y', $timestamp);
(#10850)
jonas89
Forum Newbie
Posts: 5
Joined: Thu Jan 12, 2012 4:28 pm

Re: Time convertion

Post by jonas89 »

Wicked, it worked perfectly Christopher
Post Reply