walter
walter

Reputation: 111

Timestamp to Date

Ho do I convert:

2010-12-24 11:39:43

to:

24/12 11:39

Thanks.

Upvotes: 1

Views: 407

Answers (4)

Kevin_L22
Kevin_L22

Reputation: 113

$date = DateTime::createFromFormat('Y-m-d G:i:s', 2010-12-24 11:39:43); //You can simply tell DateTime accept your timestamp as is since PHP 5.3

echo $date->format('d/m G:i T'); //Will output what you wanted + Timezone Abbreviation (because of the T) 

Upvotes: 1

user432219
user432219

Reputation:

Try:

$unixtime = strtotime("2010-12-24 11:39:43");

$newFormat = date("d/m H:i", $unixtime);

Upvotes: 4

Dejan Marjanović
Dejan Marjanović

Reputation: 19380

echo date("d/m H:i", strtotime("2010-12-24 11:39:43"));

Upvotes: 3

Jan Hančič
Jan Hančič

Reputation: 53929

This should to the trick:

$newFormat = Date ( 'd/m H:i', StrToTime ( '2010-12-24 11:39:43' ) );

You use StrToTime to convert a string representation of a date to timestamp. You then feed that timestamp to the Date function that takes the format of the date as the first parameter.

Upvotes: 5

Related Questions