Computing.Net > Forums > Unix > How to get current date -1 hr

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How to get current date -1 hr

Reply to Message Icon

Name: Joe Richardson
Date: January 10, 2003 at 12:38:13 Pacific
OS: UNIX
CPU/Ram: N/A
Comment:

Hi,

Does anyone know of a UNIX command that will return the current date minus 1 hr?

For example, if I the current date command returns "Fri Jan 10 14:08:15 EST 2003", what command would return "Fri Jan 10 13:08:15 EST 2003"?



Sponsored Link
Ads by Google

Response Number 1
Name: LANkrypt0
Date: January 10, 2003 at 13:19:14 Pacific
Reply:

Ugh, not one of these again :)

Are you just looking for the hour change? Or date as well.

i.e if the time is 01.14.33 it sets to 24.14.33, and the day rolls back one. If you do it on the first of the month, the and month rolls back one, the first of the year, the the the year rolls back one.

So really specify what you are looking for here :)


0

Response Number 2
Name: James Boothe
Date: January 10, 2003 at 13:49:22 Pacific
Reply:

Assuming that your $TZ is currently set to EST5EDT, you should be able to do:

TZ=EST6EDT date

which asks for the current date and time as if EST were 6 hours from UTC rather than 5.

Also, executed in the manner above will impact only that one date command, and will not change the current shell value for TZ.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: How to get current date -1 hr

How to check date in unix www.computing.net/answers/unix/how-to-check-date-in-unix/3115.html

how to get the last field www.computing.net/answers/unix/how-to-get-the-last-field/6529.html

How to get CRON to read .profile www.computing.net/answers/unix/how-to-get-cron-to-read-profile/5351.html