2

I'm using a custom plugin in wordpress. All date and time are stored in database as UTC. I saw in posts table, there're 2 columns for UTC and local timezone (post_date, post_date_gtm), but in this plugin table, there's only 1 column to store the created date as UTC.

Currently, I'm using sql query and $wpdb to show the data between "start date" and "end date". Please help me to show them in local timezone (That is setted in general setting) instead of UTC!

Thanks and sorry about my English.

mrdeeds88
  • 115
  • 1
  • 7

3 Answers3

2

Assume your local time zone is +05:00, use the following condition:

WHERE CONVERT_TZ(col_date_utc, '+00:00', '+05:00') BETWEEN '....' AND '....'
Dylan Su
  • 5,975
  • 1
  • 16
  • 25
  • Thank you! I have a small question:I use gtm_offset and it return for exp: -7.5, How can I convert this to -07:30, is there any function in wordpress support this? – mrdeeds88 Mar 30 '16 at 03:37
2

I thought this might be useful

There are 3 places where the timezone might be set in MySQL: Check here link

Community
  • 1
  • 1
krunal sojitra
  • 385
  • 1
  • 5
1

Have you tried Admin> Settings> Timezone?