mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-23 21:53:09 +02:00
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
This commit is contained in:
@@ -3,17 +3,12 @@ title: time.Format
|
||||
description: Returns the given date/time as a formatted and localized string.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: [dateFormat]
|
||||
related:
|
||||
- functions/time/AsTime
|
||||
- functions/time/Duration
|
||||
- functions/time/Now
|
||||
- functions/time/ParseDuration
|
||||
returnType: string
|
||||
signatures: [time.Format LAYOUT INPUT]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: [dateFormat]
|
||||
returnType: string
|
||||
signatures: [time.Format LAYOUT INPUT]
|
||||
aliases: [/functions/dateformat]
|
||||
toc: true
|
||||
---
|
||||
|
||||
Use the `time.Format` function with `time.Time` values:
|
||||
@@ -32,7 +27,7 @@ Or use `time.Format` with a parsable string representation of a date/time value:
|
||||
|
||||
Examples of parsable string representations:
|
||||
|
||||
{{% include "functions/time/_common/parsable-date-time-strings.md" %}}
|
||||
{{% include "/_common/parsable-date-time-strings.md" %}}
|
||||
|
||||
To override the default time zone, set the [`timeZone`] in your site configuration. The order of precedence for determining the time zone is:
|
||||
|
||||
@@ -40,17 +35,17 @@ To override the default time zone, set the [`timeZone`] in your site configurati
|
||||
1. The time zone specified in your site configuration
|
||||
1. The `Etc/UTC` time zone
|
||||
|
||||
[`timeZone`]: /getting-started/configuration/#timezone
|
||||
[`timeZone`]: /configuration/all/#timezone
|
||||
|
||||
## Layout string
|
||||
|
||||
{{% include "functions/_common/time-layout-string.md" %}}
|
||||
{{% include "/_common/time-layout-string.md" %}}
|
||||
|
||||
## Localization
|
||||
|
||||
Use the `time.Format` function to localize `time.Time` values for the current language and region.
|
||||
|
||||
{{% include "functions/_common/locales.md" %}}
|
||||
{{% include "/_common/functions/locales.md" %}}
|
||||
|
||||
Use the layout string as described above, or one of the tokens below. For example:
|
||||
|
||||
|
Reference in New Issue
Block a user