Wednesday, August 14, 2013

How to get time and Date from datetime stamp in php and mysql?

You can use the strtotime php function to separate date and time from datetime string. It can come in handy when you need to separate date and time from datetime format in the mysql database.
   $datetime = '2013-08-14 11:45:45';
   echo date("Y-m-d",strtotime($datetime)); // output 2013-08-14
   echo  date("H:i:s",strtotime($datetime)); // output 11:45:45
Small and simple solution. :)

1 comment: