Date
date— Date-related commands.date from-human— Convert a human readable datetime string to a datetime.date humanize— Print a ‘humanized’ format for the date, relative to now.date list-timezone— List supported time zones.date now— Get the current date.date to-timezone— Convert a date to a given time zone.
Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.
Tips
Intro
date now reads the current time.
date now
format date can print just the year.
date now | format date "%Y"
Basic
The year text can become an integer.
date now | format date "%Y" | into int
The month text can become an integer.
date now | format date "%m" | into int
Intermediate
Year, integer, then text again.
date now | format date "%Y" | into int | into string
Split a year-month string into parts.
date now | format date "%Y-%m" | split row "-" | length
Advanced
Four steps from the year to a count.
date now | format date "%Y" | into string | str length | math abs