kks_krishna Posted July 5, 2007 Share Posted July 5, 2007 HI, I am getting the date from mysql as "2007-07-04 18:00:55" in this format. While displaying I want to show as "04/07/2007". How can I format like that? Thanks, Krishna Quote Link to comment Share on other sites More sharing options...
john010117 Posted July 5, 2007 Share Posted July 5, 2007 I made this function a while ago. <?php function date_time_sep($date_time) { global $res_date,$res_time; $date = substr($date_time, -19, 10); $time = substr($date_time, -8, 5); // Date $year = substr($date, 0,4); $month = substr($date, 5, 2); $day = substr($date, 8, 2); $res_date = date("D M jS, Y", mktime(0, 0, 0, $month, $day, $year)); // Time $time_format = $time . ' ' . strtolower(strftime("%p")); $res_time = $time_format; } ?> Use $res_date to display the date and $res_time to display the time. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted July 5, 2007 Share Posted July 5, 2007 some one might have a more efficient way but this how i do it now. <?php $date="2007-07-04 18:00:55"; list($year,$month,$daytime)=explode('-',$date); list($day,$time)=explode(" ",$daytime); echo date("m/d/Y",mktime(0,0,0,$month,$day,$year)); ?> Quote Link to comment 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.