-2

I have an ISO-8601 datetime stamp, and need to convert it into local time in GMT. What is the way to do it in Ruby on Rails? I have '1325233011', and need to convert it into local time in GMT standards.

sawa
  • 165,429
  • 45
  • 277
  • 381
Taimoor Changaiz
  • 10,250
  • 4
  • 49
  • 53

2 Answers2

2

I think what you're asking for is a locale time in GMT+5.

Given an ISO timestamp, 1325233011

When I convert this to a locale-based date/time

Time.at(1325233011) => '2011-12-30 03:16:51 -0500'

Take a look at the ruby-docs, http://www.ruby-doc.org/core-1.9.3/Time.html for more information. Ruby has robust Time and Date classes with many helper utilities. My machine is configured for GMT-5 so it returns the local time. It's easy to change the way timezone settings are interpreted in your program, but that's for another day. Hope this helps!

Gui LeFlea
  • 795
  • 3
  • 12
  • thanks @user1863592 but I got your answer when I find mine I also upovter your answer as you responded instantly and accuratly thanks :) – Taimoor Changaiz Feb 14 '13 at 20:53
-1

From Collegue's help got it

Time.at(1325233011).to_datetime

For Iso-8601:

Time.at(1325233011).to_datetime.iso8601

For verification of time correct conversion and comparision use this link http://coderstoolbox.net/unixtimestamp/

Taimoor Changaiz
  • 10,250
  • 4
  • 49
  • 53