Reputation: 6203
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
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