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.
1 Answer
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.
1 Comment
Siraj Khan
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));
too broad. Have you googled before coming here ?