Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert UTC time to PST?

Tags:

sql

sqlite

My table has date column in UTC time zone. I want to convert the data into PST. How to do this?

UTC time:

date
2017-06-26 17:35:47.0
2017-06-26 17:35:51.0
2017-06-26 17:28:04.0
2017-06-26 17:35:51.0
2017-06-26 17:35:45.0
2017-06-26 17:35:51.0
2017-06-26 17:35:51.0
2017-06-26 17:35:27.0
2017-06-26 17:35:27.0
2017-06-26 17:35:51.0
2017-06-26 17:35:51.0
2017-06-26 17:35:51.0
2017-06-26 17:35:51.0
like image 596
sande Avatar asked Oct 23 '25 16:10

sande


1 Answers

For table test_table with column date_column containing datetime, to get local time from UTC you can use:

SELECT datetime(date_column,'localtime') as local_time from test_table;

Example with IST (UTC is 5 hours and 30 minutes behind of IST):

SELECT datetime(date_column||"-05:30") as local_time from test_table;
like image 96
Fathah Rehman P Avatar answered Oct 25 '25 05:10

Fathah Rehman P