Back to Oh My Posh

Time

website/docs/segments/system/time.mdx

29.12.04.0 KB
Original Source

What

Show the current timestamp.

Sample Configuration

import Config from "@site/src/components/Config.js";

<Config data={{ type: "time", style: "plain", foreground: "#007ACC", options: { time_format: "15:04:05", }, }} />

Options

NameTypeDefaultDescription
time_formatstring15:04:05Format to use

Template (info)

:::note default template

template
 {{ .CurrentDate | date .Format }}

:::

Properties

NameTypeDescription
.FormatstringThe time format (set via time_format)
.CurrentDatetimeThe time to display (testing purpose)

Syntax

Formats

Follows the golang datetime standard:

DateTimeFormat
Year06, 2006
Month01, 1, Jan, January
Day02, 2, _2 <sub>(width two, right justified)</sub>
WeekdayMon, Monday
Hours03, 3, 15
Minutes04, 4
Seconds05, 5
ms μs ns.000, .000000, .000000000
ms μs ns <sub>(trailing zeros removed)</sub>.999, .999999, .999999999
am/pmPM, pm
TimezoneMST
Offset-0700, -07, -07:00, Z0700, Z07:00

Predefined formats

The following predefined date and timestamp format constants are also available:

NameFormat
ANSICMon Jan _2 15:04:05 2006
UnixDateMon Jan _2 15:04:05 MST 2006
RubyDateMon Jan 02 15:04:05 -0700 2006
RFC82202 Jan 06 15:04 MST
RFC822Z02 Jan 06 15:04 -0700
RFC850Monday, 02-Jan-06 15:04:05 MST
RFC1123Mon, 02 Jan 2006 15:04:05 MST
RFC1123ZMon, 02 Jan 2006 15:04:05 -0700
RFC33392006-01-02T15:04:05Z07:00
RFC3339Nano2006-01-02T15:04:05.999999999Z07:00
Kitchen3:04PM
StampJan _2 15:04:05
StampMilliJan _2 15:04:05.000
StampMicroJan _2 15:04:05.000000
StampNanoJan _2 15:04:05.000000000

Examples

To display the time in multiple time zones, using Sprig's Date Functions:

text
{{ .CurrentDate | date .Format }} {{ dateInZone "15:04Z" .CurrentDate "UTC" }}