0

The following MYSQL query returns a date as expected:

select str_to_date('Thu, 13 May 2021 10:40:00 +0000',
                     '%a, %d %b %Y %H:%i:%s +0000') the_date;
+---------------------+
| the_date            |
+---------------------+
| 2021-05-13 10:40:00 |
+---------------------+
1 row in set (0.00 sec)

The date value string is from another data source with the timezone UTC.

I need to ensure this is correctly adjusted for London (GMT in Winter, BST or GMT+1 in Summer). For this I am trying to use convert_tz as follows, but the result is NULL:

select convert_tz(str_to_date('Thu, 13 May 2021 10:40:00 +0000',
                              '%a, %d %b %Y %H:%i:%s +0000'),
                  'UTC', 'Europe/London') the_date;
+----------+
| the_date |
+----------+
| NULL     |
+----------+
1 row in set (0.00 sec)

Why NULL?

TenG
  • 3,843
  • 2
  • 25
  • 42
  • 1
    Have you imported the time zone definitions into MySQL? – matigo May 16 '21 at 01:30
  • No. I am running `10.1.19-MariaDB` under Xampp on Windows. I have located `"C:\Devtools\xampp\mysql\bin\mysql_tzinfo_to_sql.exe"` but where is the tzinfo file? Also I have seen posts that say there is no need to run this on Windows. – TenG May 16 '21 at 15:29
  • It's OK, thanks for the hint. I downloaded the script from https://dev.mysql.com/downloads/timezones.html and ran it. Working now. – TenG May 16 '21 at 15:42
  • Does this answer your question? [convert\_tz returns null](https://stackoverflow.com/questions/14454304/convert-tz-returns-null) – Oded Ben Dov Apr 10 '22 at 18:00

0 Answers0