HCProfessionals Posted March 20, 2011 Share Posted March 20, 2011 Is it possible to convert time(); to date();? Quote 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? Quote 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); Quote 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; } ?> Quote 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); Quote Link to comment https://forums.phpfreaks.com/topic/231154-convert-time-to-date/#findComment-1189834 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.