COS-General

Can I use a custom date format for my blog?

Last updated: December 5, 2016

Available For:

Marketing: Basic, Pro, Enterprise
Sales: N/A

When configuring your blog's Publish Date and Posts by Month formats, you have the option to select from a list of built-in date formats. You may also create completely customized date formats using the Locale Data Markup Language specification (LDML).

To create and use a custom date format for your blog Publish Date or Posts by Month:

  • Navigate in HubSpot Marketing to ContentContent SettingsBlog Date Formats
  • Find the format you'd like to edit (Publish Date or Posts by Month) and select Custom format... to the right

  • Select Create date format
  • Click Save changes to apply these changes to your blog

 

Custom Date Formats

The Locale Data Markup Language specification (LDML) defines these formats as follows:

A date/time pattern is a string of characters, where specific strings of characters are replaced with date and time data from a calendar when formatting or used to generate data for a calendar when parsing. […]

Characters may be used multiple times. For example, if y is used for the year, yy might produce "99", whereas yyyy produces "1999". For most numerical fields, the number of characters specifies the field width. For example, if h is the hour, h might produce "5", but hh produces "05". For some characters, the count specifies whether an abbreviated or full form should be used […]

Two single quotes represent a literal single quote, either inside or outside single quotes. Text within single quotes is not interpreted in any way (except for two adjacent single quotes).

Below are some formatting examples for the date April 1, 2013 at 3:30 PM:

Language Format Pattern Date Displayed
English (United States) EEE, MMM d, ''yy Sat, Apr 1, '13
German EEEE, d.M.yyyy Sonntag, 1.4.2013
English (United States) hh 'o''clock' a 03 o'clock PM
German H:mm a 15:30 nachm.
English (United States) yyyyy.MMMM.dd GGG hh:mm a 02013.April.01 AD 03:30 PM

The syntax for custom datetime format patterns is described in detail in the Locale Data Markup Language specification. The following tables are a relatively brief overview. (Source: Babel User Guide)

Date Fields:

Field Symbol Description
Era G Replaced with the era string for the current date. One to three letters for the abbreviated form, four letters for the long form, five for the narrow form
Year y Replaced by the year. Normally the length specifies the padding, but for two letters it also specifies the maximum length.
Y Same as y but uses the ISO year-week calendar.
Quarter Q Use one or two for the numerical quarter, three for the abbreviation, or four for the full name.
q Use one or two for the numerical quarter, three for the abbreviation, or four for the full name.
Month M Use one or two for the numerical month, three for the abbreviation, or four for the full name, or five for the narrow name.
L Use one or two for the numerical month, three for the abbreviation, or four for the full name, or 5 for the narrow name.
Week w Week of year.
W Week of month.
Day d Day of month.
D Day of year.
F Day of week in month.
Week day E Day of week. Use one through three letters for the short day, or four for the full name, or five for the narrow name.
e Local day of week. Same as E except adds a numeric value that will depend on the local starting day of the week, using one or two letters.


Time Fields:

Field Symbol Description
Period a AM or PM
Hour h Hour [1-12].
H Hour [0-23].
K Hour [0-11].
k Hour [1-24].
Minute m Use one or two for zero places padding.
Second s Use one or two for zero places padding.
S Fractional second, rounds to the count of letters.
A Milliseconds in day.
Timezone z Use one to three letters for the short timezone or four for the full name.
Z Use one to three letters for RFC 822, four letters for GMT format.
v Use one letter for short wall (generic) time, four for long wall time.
V Same as z, except that timezone abbreviations should be used regardless of whether they are in common use by the locale.