Re: formatting time string from: 2007-05-30 11:46: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)datepart s[1]."/".(int)datepart s[2];
And for dates up to the 13th of the month, is ambiguous
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Comment