Date: Difference between revisions

From wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 1: Line 1:
[[Category: Linux/Unix]]
;TIMESTAMP=`date +%s%N`
;TIMESTAMP=`date +%s%N`
:Pretty unique timestamp (seconds since 1-1-1970 and current nanosecond)
:Pretty unique timestamp (seconds since 1-1-1970 and current nanosecond)
Line 7: Line 9:
;<nowiki>YESTERDAY=`date -d "yesterday 13:00" +%Y%m%d`</nowiki>
;<nowiki>YESTERDAY=`date -d "yesterday 13:00" +%Y%m%d`</nowiki>
:DST safe way to get yesterday, just using yesterday between 23:00 and 01:00 can have unwanted result.
:DST safe way to get yesterday, just using yesterday between 23:00 and 01:00 can have unwanted result.
:Other words can be used too 'Next Month','Next Monday',...

Latest revision as of 16:26, 4 July 2024


TIMESTAMP=`date +%s%N`
Pretty unique timestamp (seconds since 1-1-1970 and current nanosecond)
TIMESTAMP=`date +%Y%m%d_%H%M`
Common timestamp (Year, month, day, hour, minute)
YESTERDAY=`date -d "yesterday 13:00" +%Y%m%d`
DST safe way to get yesterday, just using yesterday between 23:00 and 01:00 can have unwanted result.
Other words can be used too 'Next Month','Next Monday',...