Forum Moderators: coopster

Message Too Old, No Replies

Conversion of TimeStamps

How can you convert this to a formatted string?

         

Eric_Lander

7:01 pm on Jun 20, 2005 (gmt 0)

10+ Year Member



I'm reviewing a client's datafeed and their currently using something that looks like this:

2005-06-20T11:00:00

...for the representation of meeting dates for their sales teams. I'm working on an interface where these teams can log in, review applicable meetings, and find out when these meetings are taking place.

The only problem... I cannot for the life of me figure out how to convert these strings into anything resembling a formatted date.

Does anyone know how to do this?

jatar_k

7:19 pm on Jun 20, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I find the best way is to always go to unix timestamp and then go from there. I used this little script to demonstrate the conversion.

<?
$tstr = '2005-06-20T11:00:00';
echo '<p>orig: ',$tstr;

$tstr2 = strtotime [php.net]($tstr);
echo '<p>after strtotime: ',$tstr2;

$ftime = strftime('%r %A %B %d, %Y',$tstr2);
echo '<p>formatted output:<br>',$ftime;
?>

you just need to apply your desired format to strftime [php.net]

Burner

2:26 am on Jun 21, 2005 (gmt 0)

10+ Year Member



you could also try:

$your_formatted_date = date("D, Y-m-d", strtotime("2005-06-20T11:00:00"));

You can catch the format codes for date at [php.net...]