Mutley Posted January 9, 2007 Share Posted January 9, 2007 If I'm inserting time into a database, how do I format it?$time = time();Is what I have but that is seconds from 1970 or something, I want it to be hours/minutes/seconds in 24 hour style. Quote Link to comment https://forums.phpfreaks.com/topic/33409-time/ Share on other sites More sharing options...
Jessica Posted January 9, 2007 Share Posted January 9, 2007 if you want to insert the current time, use NOW();$sql = "INSERT INTO table VALUES(now())";otherwise use time() and format it with date(). DATETIME in mysql is YYYY-MM-DD HH:MM:SS ("Y-m-d H:i:s")Date is same without the time ;) Quote Link to comment https://forums.phpfreaks.com/topic/33409-time/#findComment-156252 Share on other sites More sharing options...
curtis_b Posted January 9, 2007 Share Posted January 9, 2007 what's the data type in mysql?check out date()http://us3.php.net/manual/en/function.date.phptry date(G:i:s) Quote Link to comment https://forums.phpfreaks.com/topic/33409-time/#findComment-156256 Share on other sites More sharing options...
marcus Posted January 9, 2007 Share Posted January 9, 2007 To use the date function to get hour/min/sec you do:[code=php:0]$date = date("h/i/s");//if you want the 24-hour time syntax$date = date("H/i/s");[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33409-time/#findComment-156295 Share on other sites More sharing options...
Mutley Posted January 9, 2007 Author Share Posted January 9, 2007 How does displaying different timezones work? GMT for example. Quote Link to comment https://forums.phpfreaks.com/topic/33409-time/#findComment-156606 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.