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 [2018-10-08T15:50:30+0200]
Wolfgang
unix:date [2021-07-15T07:52:10+0200] (current)
Wolfgang
Line 1: Line 1:
 ====== Date and Time ====== ====== Date and Time ======
  
-  date +%FT%T%z+ 
 + 
 +===== 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> 
 +date +%FT%T%z 
 +</sxh>
      
 ===== Get Time of Different Time Zone ===== ===== Get Time of Different Time Zone =====
-  ls /usr/share/zoneinfo/Asia +<sxh bash> 
-  TZ='Asia/Tokyo' date+ls /usr/share/zoneinfo/Asia 
 +TZ='Asia/Tokyo' date 
 +</sxh> 
 + 
 +===== Convert UNIX Timestamp to Date ===== 
 +<sxh bash> 
 +date -r 1420888742 # BSD date 
 +date -d @1420888742 # GNU date 
 +</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.1539006630.txt.gz
  • Last modified: 2018-10-08T15:50:30+0200
  • by Wolfgang