0

How do I store dates and time from an online form I have into an SQL database using PHP? The date/time function is working quite ok.

4
  • Question is too broad . Have you googled before coming here ? Commented Nov 21, 2013 at 8:15
  • 1
    Ansers to this question to stackoverflow will be helpfull.[enter link description here][1] [1]: stackoverflow.com/questions/13671185/… Commented Nov 21, 2013 at 8:16
  • take value and put to database Commented Nov 21, 2013 at 8:18
  • Yeah. I"ve googled, just not giving me answers. Commented Nov 21, 2013 at 8:20

1 Answer 1

0

You should use the datetime datatype for your requirement. It will store both the date and time from your input field based on your query.

For retrieving the datetime you can use the mysql's date_format() function or PHP's date() function. The datetime will always be stored according to the server's time and not on the clients time.

Sign up to request clarification or add additional context in comments.

1 Comment

normally we use the PHP date function and that way if you ever want to store the time relative to the user's timezone you can simply change the timezone based off the user's settings. When you pull it out of the database, use strtotime() to convert it, then you can use all the date() features to display it however you want. Example: echo date('F j, Y',strtotime($db_datetime));

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.