unix:date

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
unix:date [2019-01-08T21:42:31+0100]
Wolfgang
unix:date [2021-07-15T07:52:10+0200] (current)
Wolfgang
Line 1: Line 1:
 ====== Date and Time ====== ====== Date and Time ======
  
 +
 +
 +===== Convert UNIX Timestamp =====
 +
 +GNU:
 +<code>
 +date -d "@$TIMESTAMP"
 +</code>
 +
 +UNIX/macOS:
 +<code>
 +date -r "$TIMESTAMP"
 +</code>
 +
 +strftime:
 +<code>
 +echo "$TIMESTAMP" | gawk '{print strftime("%c", $0)}'
 +</code>
 +
 +===== ISO 8601 Timestamp =====
 <sxh bash> <sxh bash>
 date +%FT%T%z date +%FT%T%z
Line 16: Line 36:
 date -d @1420888742 # GNU date date -d @1420888742 # GNU date
 </sxh> </sxh>
 +
 +===== Convert UTC to local time (GNU date) =====
 +<code>
 +date -d '2021-02-19 23:42UTC'
 +</code>
 +
 +===== Convert time to UTC (GNU date) =====
 +
 +specifying date and timezone:
 +<code>
 +date -u -d "2021-02-19 23:42 CET" +"%Y-%m-%d %H:%M %Z"
 +</code>
 +
 +using current system time:
 +<code>
 +date -u +"%Y-%m-%d %H:%M %Z"
 +</code>
 +
  
  • unix/date.1546980151.txt.gz
  • Last modified: 2019-01-08T21:42:31+0100
  • by Wolfgang