Zubair
Zubair

Reputation: 6203

How to get date and time from rfc399 ruby

How to get date and time form the following timestamp or parse date:

2015-09-23T07:12:54.404Z

Need to display time in format 23-09-2015, 7:54Am. Also need to get timeZone.

Upvotes: 1

Views: 116

Answers (1)

pangpang
pangpang

Reputation: 8821

DateTime.parse("2015-09-23T07:12:54.404Z")

DateTime.parse("2015-09-23T07:12:54.404Z").strftime("%d-%m-%Y,%H:%M:%S")
=> "23-09-2015,07:12:54"

DateTime.parse("2015-09-23T07:12:54.404Z").strftime("%d-%m-%Y,%H:%M:%S%P")
=> "23-09-2015,07:12:54am"

if you want to get timeZone, just need to add %z or %Z.

Upvotes: 2

Related Questions