Time

November 19, 2018

So, much ado about date and time stampings. The format for dates in Hugo by default is:

date: 2018-11-19T10:27:05-05:00

This date format appears to be a version from RFC 3339, section 5.8.

To generate the time on a BSD machine in this format, you'll need to generate a custom format string for the date option. This will mean perusing strftime(3) once again, unless you can remember all those little conversion specs.

To save you (and me) time later, here is how to format the string for the date(1) command.

The first try is:

date -j "+%Y-%m-%dT%k:%M:%S%z"

This produces

2018-11-19T10:57:46-0500

which is almost good except it's missing the last colon between the hours and minutes in the timezone 2018-11-19T10:57:46-0500

There's isn't an option on the strftime(3) page for formatting the timezone like that, so we'll have to fake it:

date -j "+%Y-%m-%dT%k:%M:%S-05:00"

and then remember to change it during the changes to and from Daylight Savings Time

Until all that gets trashed by politicos...

--Jim B.

NB: I had to use markup: mmark and smartypants: false in the frontmatter of this document to get the quotes working correctly. Mmark is better for using quotes in technical documents.

Tags: time hugo