|
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]
|