Jump to content

date and time that are auto inserted into my database are wrong


sandrine

Recommended Posts

when i insert some info into my mysql using a form on my website the date and time that are auto inserted into my database are wrong. the date is minus one day and the time is also many hours behind.

iam using a form to get the info and a simlpe php script does the inserting into my database.

can any one point me in the right direction thanks.

NTP is short for Network Time Protocol. It's a protocol for synchronizing clocks. You can only set that up if you are the administrator of the server. I don't know if your server's clock is off though. You can check that yourself by echoing the date and time to see if it's correct or not.

ok i figured it out you can change the time zone quite eqsily but i cant as iam on a free hosting so cant access .htaccess fully or php.ini at all. the server is in the usa and iam in the uk so i need to either upgrade and get paid hosting or find a free host based in the uk thanks for the help tho.

Postgre's timestamp fields support with timezone or without timezone.  If the database you are using does the same, then you can just insert it with the correct timezone and display it with the user's timezone.  Then it will all be correct!

  • 2 months later...

Really simple way would be to add the hours on.

So any time zone is a whole number of hours plus or minus of gmt.

Just work out the difference and before you post the date to the table add or subtract the difference.

 

Very quick and dirty. :-)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.