HCProfessionals Posted March 20, 2011 Share Posted March 20, 2011 Is it possible to convert time(); to date();? Link to comment https://forums.phpfreaks.com/topic/231154-convert-time-to-date/ Share on other sites More sharing options...
kenrbnsn Posted March 20, 2011 Share Posted March 20, 2011 What do you mean? Link to comment https://forums.phpfreaks.com/topic/231154-convert-time-to-date/#findComment-1189805 Share on other sites More sharing options...
QuickOldCar Posted March 20, 2011 Share Posted March 20, 2011 use the variable $timestamp for your current timestamp values $datetime = date("Y-m-d H:i:s", $timestamp); Link to comment https://forums.phpfreaks.com/topic/231154-convert-time-to-date/#findComment-1189831 Share on other sites More sharing options...
QuickOldCar Posted March 20, 2011 Share Posted March 20, 2011 here's an example <?php $timestamp ="1128831859"; $datetime = date("Y-m-d H:i:s", $timestamp); echo $datetime; ?> I guess can make it a function too <?php function convertDateTime($timestamp){ $datetime = date("Y-m-d H:i:s", $timestamp); return $datetime; } ?> Link to comment https://forums.phpfreaks.com/topic/231154-convert-time-to-date/#findComment-1189832 Share on other sites More sharing options...
QuickOldCar Posted March 20, 2011 Share Posted March 20, 2011 Just for reference here's to do it the other way too. $timestamp = strtotime($date); Link to comment https://forums.phpfreaks.com/topic/231154-convert-time-to-date/#findComment-1189834 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.