PHP string to Date and Time
I have the following string开发者_如何学C: 2010-04-08T12:46:43+00:00
I want to convert that to:
8th April 2010 @ 12:46
Is that easy enough?
Take a look at strtotime to create a UNIX timestamp from your time string, and then use date($format, $UNIXtimestamp); to create a normal date again:
$Timestamp = strtotime("2010-04-08T12:46:43+00:00");
echo date("your time format", $Timestamp);
You can look up the specific characters for the time format from PHP.net
Here you go.
EDIT : Exactly as you needed
Code:
$time_value = strtotime("2010-04-08T12:46:43+00:00");
$date_in_your_format = date( 'jS F Y @ g:i', $time_value);
echo $date_in_your_format;
yep. use strtotime() + date()
Try taking a look at strtotime()
and date()
.
精彩评论