mrdeeds88
mrdeeds88

Reputation: 163

How to change database timezone from UTC to local in wordpress

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.

Upvotes: 2

Views: 3356

Answers (3)

krunal sojitra
krunal sojitra

Reputation: 385

I thought this might be useful

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

Upvotes: 2

Virendra Singh
Virendra Singh

Reputation: 36

Have you tried Admin> Settings> Timezone?

Upvotes: 2

Dylan Su
Dylan Su

Reputation: 6065

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

WHERE CONVERT_TZ(col_date_utc, '+00:00', '+05:00') BETWEEN '....' AND '....'

Upvotes: 2

Related Questions