unemployment Posted January 26, 2011 Share Posted January 26, 2011 What is the best way to insert this time stamp into mysql? This is the info I want... Example: Sunday, 28.1.11, 9:56 How would I also select time from the database using mysql? Link to comment https://forums.phpfreaks.com/topic/225719-time-and-date/ Share on other sites More sharing options...
dragon_sa Posted January 26, 2011 Share Posted January 26, 2011 $time=time(); will give you the current timestamp on the server then just insert that in your database if you want the time of a specific location you would use putenv("TZ=Australia/Adelaide"); this would set your code to use the adelaide time zone to read the time stamp $today = date("F j, Y, g:i a", $time); Link to comment https://forums.phpfreaks.com/topic/225719-time-and-date/#findComment-1165400 Share on other sites More sharing options...
unemployment Posted January 26, 2011 Author Share Posted January 26, 2011 $time=time(); will give you the current timestamp on the server then just insert that in your database if you want the time of a specific location you would use putenv("TZ=Australia/Adelaide"); this would set your code to use the adelaide time zone to read the time stamp $today = date("F j, Y, g:i a", $time); I'll try this out, but what do I use for the "type" in mysql. Do I set the field name type to TIME? Link to comment https://forums.phpfreaks.com/topic/225719-time-and-date/#findComment-1165420 Share on other sites More sharing options...
unemployment Posted January 26, 2011 Author Share Posted January 26, 2011 I think I'm going to use $time = date(DATE_RFC822); but how do I POST the data to the database. Link to comment https://forums.phpfreaks.com/topic/225719-time-and-date/#findComment-1165427 Share on other sites More sharing options...
dragon_sa Posted January 26, 2011 Share Posted January 26, 2011 integer Link to comment https://forums.phpfreaks.com/topic/225719-time-and-date/#findComment-1165428 Share on other sites More sharing options...
unemployment Posted January 26, 2011 Author Share Posted January 26, 2011 integer Please be a little more descriptive. In the past, I have only posted data from form fields. I don't know how to post data that is just held in a variable. Link to comment https://forums.phpfreaks.com/topic/225719-time-and-date/#findComment-1165429 Share on other sites More sharing options...
Pikachu2000 Posted January 26, 2011 Share Posted January 26, 2011 The best way to store a date in a database is in the database's native date/time format. Link to comment https://forums.phpfreaks.com/topic/225719-time-and-date/#findComment-1165512 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.