gple Posted November 7, 2010 Share Posted November 7, 2010 $date=2010-11-01 23:45:09 How do I create one variable to output Monday November 1 and another variable to display 11:45:09 PM from the above variable. Link to comment https://forums.phpfreaks.com/topic/218011-get-date-and-time-separately/ Share on other sites More sharing options...
Joshua F Posted November 7, 2010 Share Posted November 7, 2010 http://php.net/manual/en/function.date.php Link to comment https://forums.phpfreaks.com/topic/218011-get-date-and-time-separately/#findComment-1131394 Share on other sites More sharing options...
gple Posted November 7, 2010 Author Share Posted November 7, 2010 $date2=date("Y-m-d", $date1); echo $date2; this keeps displaying 1969-12-31 Link to comment https://forums.phpfreaks.com/topic/218011-get-date-and-time-separately/#findComment-1131400 Share on other sites More sharing options...
Joshua F Posted November 7, 2010 Share Posted November 7, 2010 $date2=date("Y-m-d", $date1); echo $date2; this keeps displaying 1969-12-31 Would be something like this since you didn't say what $date1 is $date1 = '2010-11-07'; $date2=date("Y-m-d", $date1); echo $date2; Link to comment https://forums.phpfreaks.com/topic/218011-get-date-and-time-separately/#findComment-1131402 Share on other sites More sharing options...
gple Posted November 7, 2010 Author Share Posted November 7, 2010 $date1 = '2010-11-06 22:02:04'; $date2=date("Y-m-d", $date1); echo $date2; this is displaying 1969-12-31 Link to comment https://forums.phpfreaks.com/topic/218011-get-date-and-time-separately/#findComment-1131407 Share on other sites More sharing options...
Joshua F Posted November 7, 2010 Share Posted November 7, 2010 Try this $date1 = '2010-11-06 22:02:04'; $date2 = date('y-F d', strtotime($date1)); echo $date2; Link to comment https://forums.phpfreaks.com/topic/218011-get-date-and-time-separately/#findComment-1131409 Share on other sites More sharing options...
gple Posted November 7, 2010 Author Share Posted November 7, 2010 that works, now from the same variable $date1 = '2010-11-06 22:02:04'; how do I pull the time as 10:02:04 PM Link to comment https://forums.phpfreaks.com/topic/218011-get-date-and-time-separately/#findComment-1131417 Share on other sites More sharing options...
Joshua F Posted November 7, 2010 Share Posted November 7, 2010 By Adding h:i A. $date1 = '2010-11-06 22:02:04'; $date2 = date('y-F d h:i A', strtotime($date1)); echo $date2; Link to comment https://forums.phpfreaks.com/topic/218011-get-date-and-time-separately/#findComment-1131422 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.