1--- 2title: time.Format 3description: Converts a date/time to a localized string. 4date: 2017-02-01 5publishdate: 2017-02-01 6lastmod: 2017-02-01 7categories: [functions] 8menu: 9 docs: 10 parent: "functions" 11keywords: [dates,time,strings] 12signature: ["time.Format LAYOUT INPUT"] 13workson: [] 14hugoversion: 15relatedfuncs: [Format,now,Unix,time] 16deprecated: false 17--- 18 19`time.Format` (alias `dateFormat`) converts either a `time.Time` object (e.g. `.Date`) or a timestamp string `INPUT` into the format specified by the `LAYOUT` string. 20 21```go-html-template 22{{ time.Format "Monday, Jan 2, 2006" "2015-01-21" }} → "Wednesday, Jan 21, 2015" 23``` 24 25Note that since Hugo 0.87.0, `time.Format` will return a localized string for the current language. {{< new-in "0.87.0" >}} 26 27The `LAYOUT` string can be either: 28 29* [Go’s Layout String](/functions/format/#gos-layout-string) to learn about how the `LAYOUT` string has to be formatted. There are also some useful examples. 30* A custom Hugo layout identifier (see full list below) 31 32See the [`time` function](/functions/time/) to convert a timestamp string to a Go `time.Time` type value. 33 34 35## Date/time formatting layouts 36 37{{< new-in "0.87.0" >}} 38 39Go's date layout strings can be hard to reason about, especially with multiple languages. Since Hugo 0.87.0 you can alternatively use some predefined layout identifiers that will output localized dates or times: 40 41```go-html-template 42{{ .Date | time.Format ":date_long" }} 43``` 44 45The full list of custom layouts with examples for English: 46 47* `:date_full` => `Wednesday, June 6, 2018` 48* `:date_long` => `June 6, 2018` 49* `:date_medium` => `Jun 6, 2018` 50* `:date_short` => `6/6/18` 51 52* `:time_full` => `2:09:37 am UTC` 53* `:time_long` => `2:09:37 am UTC` 54* `:time_medium` => `2:09:37 am` 55* `:time_short` => `2:09 am` 56