2020-10-05 02:33:12 -07:00
|
|
|
---
|
|
|
|
id: time
|
|
|
|
title: Time
|
|
|
|
sidebar_label: Time
|
|
|
|
---
|
|
|
|
|
|
|
|
## What
|
|
|
|
|
|
|
|
Show the current timestamp.
|
|
|
|
|
|
|
|
## Sample Configuration
|
|
|
|
|
2023-03-31 11:55:36 -07:00
|
|
|
import Config from '@site/src/components/Config.js';
|
|
|
|
|
|
|
|
<Config data={{
|
2020-10-05 02:33:12 -07:00
|
|
|
"type": "time",
|
|
|
|
"style": "plain",
|
|
|
|
"foreground": "#007ACC",
|
|
|
|
"properties": {
|
|
|
|
"time_format": "15:04:05"
|
|
|
|
}
|
2023-03-31 11:55:36 -07:00
|
|
|
}}/>
|
2020-10-05 02:33:12 -07:00
|
|
|
|
|
|
|
## Properties
|
|
|
|
|
2024-04-04 14:20:48 -07:00
|
|
|
| Name | Type | Default | Description |
|
|
|
|
| ------------- | :------: | :--------: | ---------------------------------------------------- |
|
|
|
|
| `time_format` | `string` | `15:04:05` | format to use, follows the [golang standard][format] |
|
2020-10-05 02:33:12 -07:00
|
|
|
|
2022-02-01 03:10:46 -08:00
|
|
|
## Template ([info][templates])
|
2021-03-16 03:36:05 -07:00
|
|
|
|
2022-02-01 03:10:46 -08:00
|
|
|
:::note default template
|
2021-03-31 01:37:02 -07:00
|
|
|
|
2022-09-16 07:32:48 -07:00
|
|
|
```template
|
2022-02-01 03:10:46 -08:00
|
|
|
{{ .CurrentDate | date .Format }}
|
|
|
|
```
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
### Properties
|
|
|
|
|
2022-09-16 07:32:48 -07:00
|
|
|
| Name | Type | Description |
|
|
|
|
| -------------- | -------- | --------------------------------------- |
|
|
|
|
| `.Format` | `string` | The time format (set via `time_format`) |
|
|
|
|
| `.CurrentDate` | `time` | The time to display (testing purpose) |
|
2022-02-01 03:10:46 -08:00
|
|
|
|
2022-09-16 07:32:48 -07:00
|
|
|
## Syntax
|
2021-03-31 01:37:02 -07:00
|
|
|
|
|
|
|
- January 2, 2006 **Date**
|
|
|
|
- 01/02/06
|
|
|
|
- Jan-02-06
|
|
|
|
- 15:04:05 **Time**
|
|
|
|
- 3:04:05 PM
|
2022-09-16 07:32:48 -07:00
|
|
|
- Jan 2 15:04:05 **Timestamp**
|
|
|
|
- Jan 2 15:04:05.000000 **with microseconds**
|
2021-03-31 01:37:02 -07:00
|
|
|
- 2006-01-02T15:04:05-0700 **ISO 8601 (RFC 3339)**
|
|
|
|
- 2006-01-02
|
|
|
|
- 15:04:05
|
|
|
|
- 02 Jan 06 15:04 MST **RFC 822**
|
|
|
|
- 02 Jan 06 15:04 -0700 **with numeric zone**
|
|
|
|
- Mon, 02 Jan 2006 15:04:05 MST 27e95cb
|
|
|
|
- Mon, 02 Jan 2006 15:04:05 -0700 **with numeric zone**
|
|
|
|
|
2022-09-16 07:32:48 -07:00
|
|
|
### Formats
|
|
|
|
|
|
|
|
The following predefined date and timestamp format constants are also available:
|
|
|
|
|
|
|
|
| Name | Output |
|
|
|
|
| ------------- | ----------------------------------- |
|
|
|
|
| `ANSIC` | Mon Jan 2 15:04:05 2006 |
|
|
|
|
| `UnixDate` | Mon Jan 2 15:04:05 MST 2006 |
|
|
|
|
| `RubyDate` | Mon Jan 02 15:04:05 -0700 2006 |
|
|
|
|
| `RFC822` | 02 Jan 06 15:04 MST |
|
|
|
|
| `RFC822Z` | 02 Jan 06 15:04 -0700 |
|
|
|
|
| `RFC850` | Monday, 02-Jan-06 15:04:05 MST |
|
|
|
|
| `RFC1123` | Mon, 02 Jan 2006 15:04:05 MST |
|
|
|
|
| `RFC1123Z` | Mon, 02 Jan 2006 15:04:05 -0700 |
|
|
|
|
| `RFC3339` | 2006-01-02T15:04:05Z07:00 |
|
|
|
|
| `RFC3339Nano` | 2006-01-02T15:04:05.999999999Z07:00 |
|
|
|
|
| `Kitchen` | 3:04PM |
|
|
|
|
| `Stamp` | Jan 2 15:04:05 |
|
|
|
|
| `StampMilli` | Jan 2 15:04:05.000 |
|
|
|
|
| `StampMicro` | Jan 2 15:04:05.000000 |
|
|
|
|
| `StampNano` | Jan 2 15:04:05.000000000 |
|
2021-06-15 12:23:08 -07:00
|
|
|
|
2022-04-22 18:50:57 -07:00
|
|
|
## Examples
|
|
|
|
|
|
|
|
To display the time in multiple time zones, using [Sprig's Date Functions][sprig-date]:
|
|
|
|
|
|
|
|
```text
|
|
|
|
{{ .CurrentDate | date .Format }} {{ dateInZone "15:04Z" .CurrentDate "UTC" }}
|
|
|
|
```
|
|
|
|
|
2022-04-20 09:43:59 -07:00
|
|
|
[templates]: /docs/configuration/templates
|
2022-01-22 10:46:56 -08:00
|
|
|
[format]: https://yourbasic.org/golang/format-parse-string-time-date-example/
|
2022-04-22 18:50:57 -07:00
|
|
|
[sprig-date]: https://masterminds.github.io/sprig/date.html
|