#19. MySQL date time related query

 select CONVERT_TZ(now(), '+00:00', '+05:30') as converted_datetime;

# converted_datetime

'2022-07-06 19:28:31'

select now() as current_dt;

# current_dt

'2022-07-06 13:56:07'

select CURDATE() as current_dt;

# current_dt

'2022-07-06'

SELECT @@global.time_zone, @@session.time_zone;

# @@global.time_zone, @@session.time_zone

'SYSTEM', 'SYSTEM'

select timediff(now(),convert_tz(now(),@@session.time_zone,'+00:00'));

# timediff(now(),convert_tz(now(),@@session.time_zone,'+00:00'))

'10:00:00'

select convert_tz(now(),@@session.time_zone,'+00:00');

# convert_tz(now(),@@session.time_zone,'+00:00')

'2022-07-06 04:03:47'

select @@session.time_zone;

# @@session.time_zone

'SYSTEM'

SELECT @@system_time_zone;

# @@system_time_zone

'AEST'

SELECT TIMEDIFF(NOW(), UTC_TIMESTAMP);

# TIMEDIFF(NOW(), UTC_TIMESTAMP)

'10:00:00'

select UTC_TIMESTAMP;

# UTC_TIMESTAMP

'2022-07-06 04:07:46'

select DATE('2022-07-06 04:07:46') as d;

# d

'2022-07-06'


Comments

Popular posts from this blog

#6. Fetch time in rails

#8. nginx+puma deployment using capistrano