PDA

View Full Version : Date and time from MySql without seconds



northernladuk
08-11-2004, 03:53 PM
I am using MySQL and saving the time using the datetime function but this saves HH:mm:ss.

How can I view the time on the webpaeg without the seconds? Can I do it with a function to drop the seconds or do I have to do something with the MySQL so it doesn't save the seconds in the first place?

many thank

redcircle
08-11-2004, 07:43 PM
Assuming you are using PHP you can convert the MySQL into a unixtimestamp and output from there.


<?php
$unix = strtotime('2004-08-10 22:33:21'); //puts the mysql datetime into unix timestamp this probably can be done within mysql also
$datetime = date('F j Y h:ia',$unix); //removes seconds and adds either am/pm accordingly if you want 24hr time use a capital H for hour
?>