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 [2020-11-10T14:11:42+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 17: Line 37:
 </sxh> </sxh>
  
-==== Convert UTC to local time (GNU date) ====+===== Convert UTC to local time (GNU date) =====
 <code> <code>
 date -d '2021-02-19 23:42UTC' date -d '2021-02-19 23:42UTC'
-</date>+</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.1605013902.txt.gz
  • Last modified: 2020-11-10T14:11:42+0100
  • by Wolfgang