Hello! I had a problem with time. And not on 1, but on several hostings at once. The essence of the problem is as follows:

I have a datetime field in the table table , well, we write the current date there and everything is ok. The time is right. But when I want to display it in the format I need , I use the date and strtotime functions . Like this:

$human-date-time = date("dmY H:i", strtotime($sql_result['datetime'])); 

And here in the $ human-date-time variable, the time is one hour later than recorded in the database. Local time is correct. The time zone in PCP is Europe / Moscow .

How to make (preferably through .htaccess) time was normal? Again, this is on several hosts and on my local machine.

PS if you put the zone Europe / London then everything is ok. Time is right

  • The field named datetime - what type: TIMESTAMP or DATETIME ? - Sergiks
  • DATETIME And if you just use date ("H: i"); that time is correct, and in the Europe / London zone it is already London. The problem is only with MySQL - Jeid
  • @jeid, in datetime, time is used without converting, as far as I know. So this time brought. - Oleg Arkhipov
  • one
    I found this, because I use phpactiverecord to work with the database, then by default the date is displayed in the format DateTime :: RFC2822. Therefore, it returns the result in the following form: Tue, 21 Aug 2012 14:33:40 +0300, then if you insert date ("dmY H: i", strtotime ($ sql_result ['datetime'])) here; that time will be 15:33. But if you use a different format, the usual Ydm H: is then everything is fine. In general, the question can be considered closed, because I just change the default format. But it would still be interesting to find out why PCPs are so strangely transforming time. - Jeid

0