Link to home
Start Free TrialLog in
Avatar of Jason92s
Jason92sFlag for Afghanistan

asked on

Help with retrieving datetime field in PHP from MySQL

Hi, my MySQL table has a field called submitted_date that is a "datetime" type.  My problem is the web host's time is 1 hour ahead of our local time, so it's storing it one hour ahead of the time the user actually submitted it.  I called them and they said I can't do anything in terms of modifying a php.ini file to fix it.

In my PHP file, when the user submits the form, I set the "submitted_date" field to now() when it's inserted into MySQL.  I retrieve the date using this line:

SELECT name,  DATE_FORMAT(submitted_date, '%M %e  %l:%i%p') as newdate.....

It then shows the time as being 1 hour ahead of the actual submitted time.  I know there must be an easy way to fix this so it shows the true time it was submitted by the user, but I can't figure it out. Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Derokorian
Derokorian
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jason92s

ASKER

Thank you!