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? Quote Link to comment 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); Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
dragon_sa Posted January 26, 2011 Share Posted January 26, 2011 integer Quote Link to comment 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. Quote Link to comment 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. 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.