Page 1 of 1
date sepration issue
Posted: Thu Nov 02, 2006 7:59 am
by itsmani1
i need to separate this date like :
November 5, 2006
Sunday, 12:00 pm
which php function can help me in conversion of this date : 2006-11-05T12:00:00
Posted: Thu Nov 02, 2006 12:32 pm
by timvw
Which functions have you looked at already? And why weren't they usable?
Posted: Thu Nov 02, 2006 4:39 pm
by amir
Code: Select all
<?php
$date = "2006-11-05T12:00:00";
$convert_date = strtotime($date);
echo date("F d, Y", $convert_date).'<br>'.date("l, h a", $convert_date);
?>
Posted: Thu Nov 02, 2006 5:01 pm
by volka
strtotime can parse the iso 8601 format. But your string is not valid iso 8601. You need to add a zone designator.
If your timestamps are UTC add Z, e.g. 2006-11-05T12:00:00Z
My current timezone is gmt+1 -> 2006-11-05T12:00:00+01:00
...
Even simpler: You can ask date() for the "right" designator
Code: Select all
<?php
$zd = date('P');
$date = "2006-11-05T12:00:00";
$convert_date = strtotime($date.$zd);
echo date("F d, Y", $convert_date).'<br>'.date("l, h a", $convert_date);
?>