You are here: Re: formatting time string from: 2007-05-30 11:46:34 « PHP Programming Language « IT news, forums, messages
Re: formatting time string from: 2007-05-30 11:46:34

Posted by Erwin Moller on 06/06/07 15:34

monomaniac21 wrote:

> hi i have a time string of the form: 2007-05-30 11:46:34 i would like
> to format this to 30/5/2007, how can i do this? thanks

Hi,

You can use date() and functions like that.

Or do it the oldfashioned way: By hand with explode.
Here follows an example.
It can be written a lot shorter, but in this way you can see what happens.

$org = "2007-05-30 11:46:34";
$parts = explode(" ",$org);
// parts[0] now contains 2007-05-30
// parts[1] now contains 11:46:34

$dateparts = explode("-",parts[0]);
// dateparts[0] is now 2007
// dateparts[1] is now 05
// dateparts[2] is now 30

// assemble them, loosing the leading 0 with (int)
$result = (int)dateparts[0]."/".(int)dateparts[1]."/".(int)dateparts[2];

Not tested, but this approach works.

Regards,
Erwin Moller

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация