There are various ways to nearly get it right, but then you run into the problem of whats midnight minus one and your scripts dont make any sense any more. This gets round the problem.
For one hour ago:
-bash-3.00$ TZ=$TZ-2 date '+%D %T'
08/20/13 13:00:51
-bash-3.00$ date
Tue Aug 20 14:00:54 EEST 2013
-bash-3.00$
For 24 hours ago
-bash-3.00$ TZ=$TZ+21 date '+%D %T'
08/19/13 13:52:48
-bash-3.00$ date
Tue Aug 20 13:53:01 EEST 2013
-bash-3.00$
It all depends on the timezone in which your server resides, so you might have to play around with the TZ value to get it correct for your part of the world
No comments:
Post a Comment