Web Development

We have a ton of time formats but ISO 8601 is the International Standard for representation of dates and times. Below are the standard representation of times according to ISO8601

Year
YYYY, eg, 1983, 2001, 1988
Year and Month
YYYY-MM eg 1983-08, 1988-05, 2010-03

h5 Year, Month and Day

YYYY-MM-DD eg 1983-08-13, 1988-05-24, 2010-03-26
Year, Month, Day, Hours and Minutes
YYYY-MM-DDThh:mmTZD eg 1983-08-13T00:00+08:00
Year, Month, Day, Hours, Minutes and Seconds
YYYY-MM-DDThh:mmTZD eg 1983-08-13T00:00:13+08:00
Year, Month, Day, Hours, Minutes and Seconds
YYYY-MM-DDThh:mm:ss.sTZD 1983-08-13T00:00:13.25+08:00

Now Ruby has it’s own function to retrieve an ISO8601 formatted time:

Time.now.iso8601
=> "2015-11-05T12:59:16-05:00"
Date.today.iso8601
=> "2015-11-05"
Time.now.utc.iso8601
=> "2015-11-05T18:00:02Z"
Date.yesterday.iso8601
=> "2015-11-04"
Time.iso8601(Time.now.utc.iso8601)
=> 2015-11-05 18:01:56 UTC

Now, you have it!