开发者

Convert Date Format

I have created a script through which i retrieve values from a rss feed. One value is in following dat开发者_运维百科e format:

Thu, 14 Apr 2011 18:23:19 GMT

What i wanted this value to be in following format:

April 14, 2011 11:53 PM

How can i achieve this?

Please help me on this

Thanks

Pankaj


The DateTime class is handy for this. You can use its format() method.

$datetime = new DateTime('Thu, 14 Apr 2011 18:23:19 GMT');

echo $datetime->format('F j,Y g:i A');


$olddate = "Thu, 14 Apr 2011 18:23:19 GMT";
$newdate = date("F d, Y H:i A",strtotime($oldDate));


Try it:

echo (date('F j,Y g:i:A',strtotime($Yourinputdate)));


<?php
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone

$today = date("F j, Y, g:i a");                 // March 10, 2001, 5:16 pm
$today = date("m.d.y");                         // 03.10.01
$today = date("j, n, Y");                       // 10, 3, 2001
$today = date("Ymd");                           // 20010310
$today = date('h-i-s, j-m-y, it is w Day');     // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.');   // it is the 10th day.
$today = date("D M j G:i:s T Y");               // Sat Mar 10 17:16:18 MST 2001
$today = date('H:m:s \m \i\s\ \m\o\n\t\h');     // 17:03:18 m is month
$today = date("H:i:s");                         // 17:16:18
?>

above code taken from : http://www.php.net/manual/en/function.date.php

i didnot see you have an input so here it is:

$date = new DateTime('Thu, 14 Apr 2011 18:23:19 GMT');
echo $date->format("F j, Y g:i a");


Try this and see if it helps

echo(date('F j,Y g:i:A',strtotime(Date_From_RSS)));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜