Sponsored Content
Full Discussion: Date command
Top Forums Shell Programming and Scripting Date command Post 302143920 by gus2000 on Monday 5th of November 2007 10:51:33 AM
Old 11-05-2007
Displaying time relative to "now"

You can print the date if you're looking for "hours earlier/later than right now" by manipulating the TZ variable:

Code:
# date
Mon Nov  5 09:47:32 CST 2007

# TZ=$(((6+24*7))) date  
Mon Oct 29 09:47:37  2007

It's a bit cheap Smilie but it works. Note that I needed to start with 6 for my local timezone, and then add hours to go backward (7 days of 24 hours each).
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

date command

Using the date command how do get yesterday's date?? e.g. date '+%b%e%Y' July 30 2002 I need to get July 29 2002 using the date command. Thanx (p.s. sorry if it's a very obvious question) (6 Replies)
Discussion started by: niamo1
6 Replies

2. UNIX for Dummies Questions & Answers

Date Command

we're using HP-UX I need to change the year. What is the date command? Thanks (2 Replies)
Discussion started by: saldana
2 Replies

3. Shell Programming and Scripting

want to get previous date from date command in ksh

I want to get previous date from date command. I am using ksh shell. Exmp: today is 2008.09.04 I want the result : 2008.09.03 Please help. Thanks in advance. (4 Replies)
Discussion started by: rinku
4 Replies

4. UNIX for Dummies Questions & Answers

date command

Hi All. I'm using date -a to 'drift' the time forward / backwards. The question is - how do I know when its finished 'drifting' ? On some systems I have another time reference I can use but not always. thanks (1 Reply)
Discussion started by: Mudshark
1 Replies

5. Shell Programming and Scripting

date command

Hi is it possible to give the date command like 24th July 2009 ive tried DATE=`date "+%d%m%Y" echo $DATE that only replies 2009 correctly. not sure how to display the month in full or if unix knows how to do i.e 2nd, 24th, 3rd (1 Reply)
Discussion started by: magnia
1 Replies

6. 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

7. Shell Programming and Scripting

How to get tomorrow,yesterday date from date Command

Hi I want to get tomorrow and yesterday date from date command. My shell is KSH and server is AIX. I tried several options, but unable to do. Please help on this. Regards Rajesh (5 Replies)
Discussion started by: rajeshmepco
5 Replies

8. Shell Programming and Scripting

Find week of the year for given date using date command inside awk

Hi all, Need an urgent help on the below scenario. script: awk -F"," 'BEGIN { #some variable assignment} { #some calculation and put values in array} END { year=#getting it from array and assume this will be 2014 month=#getting it from array and this will be 05 date=#... (7 Replies)
Discussion started by: vijaidhas
7 Replies

9. HP-UX

HP/UX command to pull file name/date based on date

HI, Can anyone tell me how to pull the date and file name separated by a space using the find command or any other command. I want to look through several directories and based on a date timeframe (find -mtime -7), output the file name (without the path) and the date(in format mmddyyyy) to a... (2 Replies)
Discussion started by: lnemitz
2 Replies

10. HP-UX

awk command in hp UNIX subtract 30 days automatically from current date without date illegal option

current date command runs well awk -v t="$(date +%Y-%m-%d)" -F "'" '$1 < t' myname.dat subtract 30 days fails awk -v t="$(date --date="-30days" +%Y-%m-%d)" -F "'" '$1 < t' myname.dat awk command in hp unix subtract 30 days automatically from current date without date illegal option error... (20 Replies)
Discussion started by: kmarcus
20 Replies
DATETIME.ADD(3) 							 1							   DATETIME.ADD(3)

DateTime::add - Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object

       Object oriented style

SYNOPSIS
public DateTime DateTime::add (DateInterval $interval) DESCRIPTION
Procedural style DateTime date_add (DateTime $object, DateInterval $interval) Adds the specified DateInterval object to the specified DateTime object. PARAMETERS
o $object -Procedural style only: A DateTime object returned by date_create(3). The function modifies this object. o $interval - A DateInterval object RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure. EXAMPLES
Example #1 DateTime.add(3) example Object oriented style <?php $date = new DateTime('2000-01-01'); $date->add(new DateInterval('P10D')); echo $date->format('Y-m-d') . " "; ?> Procedural style <?php $date = date_create('2000-01-01'); date_add($date, date_interval_create_from_date_string('10 days')); echo date_format($date, 'Y-m-d'); ?> The above examples will output: 2000-01-11 Example #2 Further DateTime.add(3) examples <?php $date = new DateTime('2000-01-01'); $date->add(new DateInterval('PT10H30S')); echo $date->format('Y-m-d H:i:s') . " "; $date = new DateTime('2000-01-01'); $date->add(new DateInterval('P7Y5M4DT4H3M2S')); echo $date->format('Y-m-d H:i:s') . " "; ?> The above example will output: 2000-01-01 10:00:30 2007-06-05 04:03:02 Example #3 Beware when adding months <?php $date = new DateTime('2000-12-31'); $interval = new DateInterval('P1M'); $date->add($interval); echo $date->format('Y-m-d') . " "; $date->add($interval); echo $date->format('Y-m-d') . " "; ?> The above example will output: 2001-01-31 2001-03-03 NOTES
DateTime.modify(3) is an alternative when using PHP 5.2. SEE ALSO
DateTime.sub(3), DateTime.diff(3), DateTime.modify(3). PHP Documentation Group DATETIME.ADD(3)
All times are GMT -4. The time now is 06:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy