Sponsored Content
Top Forums Shell Programming and Scripting Need to minus one day from a date given Post 303000023 by bakunin on Monday 3rd of July 2017 05:44:36 AM
Old 07-03-2017
Quote:
Originally Posted by ektubbe
"date -d" is not supported in the version I am using
You don't need date -d for this type of things - use the TZ-variable (Time Zone) instead.

You see, time ist stored in "UTC" (universal time coordinated) in UNIX systems. the local time is just an offset from this, and this offset is set by the TZ variable, which you can change for a single command, for instance:

Code:
# TZ=GMT+1 date
Mon Jul  3 08:40:29 GMT 2017
# TZ=GMT+25 date
Sun Jul  2 08:40:37 GMT 2017

You see, adding/subtracting 24 to the TZ variable changes the output by 24 hours - which is a day. The same way you can get any arbitrary date, even in the future:

Code:
# TZ=GMT+1 date
Mon Jul  3 08:43:32 GMT 2017
# TZ=GMT+25 date
Sun Jul  2 08:43:32 GMT 2017
# TZ=GMT-23 date
Tue Jul  4 08:43:32 GMT 2017


I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to find previous month last day minus one day timestamp

Hi All, I need to find the previous month last day minus one day, using shell script. Can you guys help me to do this. My Requirment is as below: Input for me will be 2000909(YYYYMM) I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
Discussion started by: girish.raos
3 Replies

2. UNIX for Dummies Questions & Answers

print previous month (current month minus 1) with Solaris date and ksh

Hi folks month=`date +%m`gives current month Howto print previous month (current month minus 1) with Solaris date and ksh (7 Replies)
Discussion started by: slashdotweenie
7 Replies

3. Shell Programming and Scripting

how to obtain date and day of the week from `date` command

Hi, does anybody know how to format `date` command correctly to return the day of the week? Thanks -A I work in ksh.... (1 Reply)
Discussion started by: aoussenko
1 Replies

4. UNIX and Linux Applications

sqlite: calculating with dates - compare current date minus 6 months with stored record

Hi I have a table with name, date in format DD.MM.YYYY. I need to something like this (I try to explain in pseudo code) if SYSDATE (current date) minus 6 months > $expiry date print OK else print NOK with $name and $expiry date I know this is possible with Oracle. How to do this... (0 Replies)
Discussion started by: slashdotweenie
0 Replies

5. Shell Programming and Scripting

finding the previous day date and creating a file with date

Hi guys, I had a scenario... 1. I had to get the previous days date in yyyymmdd format 2. i had to create a file with Date inthe format yyyymmdd.txt format both are different thanks guys in advance.. (4 Replies)
Discussion started by: apple2685
4 Replies

6. AIX

Need to get the next day's date of the user entered date

I need to get the next day's date of the user entered date for example: Enter date (yyyy/mm/yy): 2013/10/08I need to get the next day's date of the user entered date Desired Output: 2013/10/09Though there are ways to achieve this is Linux or Unix environment (date command) ,I need to... (1 Reply)
Discussion started by: rpm120
1 Replies

7. HP-UX

Actual date minus six months (HP UX)

Hi there, is it possible to get the actual date minux six months with just a simple command? It's easy with Linux but on HP Unix (for me) impossible ;) Best wishes (3 Replies)
Discussion started by: System
3 Replies

8. Homework & Coursework Questions

How to minus 2 month from current date?

I am running a script in ksh to get the 2 months back date from system date.The below code is giving correct date output from putty command prompt.But while running the script is .ksh file it is giving the error below.Please suggest. ; d=a; y=a m-=num while(m < 1) {m+=12; y--}... (1 Reply)
Discussion started by: hini
1 Replies

9. Shell Programming and Scripting

Date minus 1 day

Hi the below code is failing i am trying to generate do the following: 2014-10-22 11:26:00 (Substract 24 hrs) should produce 2014-10-21 11:26:00 I need the same formatting below because that gets inputted into code for an... (4 Replies)
Discussion started by: Samuel12
4 Replies

10. UNIX for Beginners Questions & Answers

Replace date in file every day with current date

I Have text like XXX_20190908.csv.gz need to replace Only date in this format with current date every day Thanks! (1 Reply)
Discussion started by: yamasani1991
1 Replies
rtc(1M)                                                   System Administration Commands                                                   rtc(1M)

NAME
rtc - provide all real-time clock and GMT-lag management SYNOPSIS
/usr/sbin/rtc [-c] [-z zone-name] DESCRIPTION
On x86 systems, the rtc command reconciles the difference in the way that time is established between UNIX and MS-DOS systems. UNIX systems utilize Greenwich Mean Time (GMT), while MS-DOS systems utilize local time. Without arguments, rtc displays the currently configured time zone string. The currently configured time zone string is based on what was last recorded by rtc-z zone-name. The rtc command is not normally run from a shell prompt; it is generally invoked by the system. Commands such as date(1) and rdate(1M), which are used to set the time on a system, invoke /usr/sbin/rtc -c to ensure that daylight savings time (DST) is corrected for properly. OPTIONS
-c This option checks for DST and makes corrections if necessary. It is normally run once a day by a cron job. If there is no RTC time zone or /etc/rtc_config file, this option will do nothing. -z zone-name This option, which is normally run by the system at software installation time, is used to specify the time zone in which the RTC is to be maintained. It updates the configuration file /etc/rtc_config with the name of the specified zone and the current GMT lag for that zone. If there is an existing rtc_config file, this command will update it. If not, this command will create it. FILES
/etc/rtc_config The data file used to record the time zone and GMT lag. This file is completely managed by /usr/sbin/rtc, and it is read by the kernel. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Architecture |x86 | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
date(1), rdate(1M), attributes(5) SunOS 5.10 3 Oct 2003 rtc(1M)
All times are GMT -4. The time now is 05:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy