Programming Ruby

Ruby convert time UTC to local TimeZone and readable format

How to convert UTC time to local TimeZone with the human-readable format

datetimeutc = "2018-09-05 05:54:53 UTC"
  => "2018-09-05 05:54:53 UTC"

datetimeutc.in_time_zone('Asia/Dhaka')
  => Wed, 05 Sep 2018 11:54:53 BDT +06:00

Now this date-time convert to human readable

format = datetimeutc.in_time_zone('Asia/Dhaka')
  => Wed, 05 Sep 2018 11:54:53 BDT +06:00 

format.strftime("%d %b, %y at %I : %M %p")
  => "05 Sep, 18 at 11 : 54 AM"

 

Fool Dev

I didn't get trained by the school system like other kids, and when I did concentrate on learning, my mind was cluttered and locked by the programming of the system. © Huey Newton