Sponsored Content
Top Forums Shell Programming and Scripting Get date and time for past 1 hour from current date Post 302152778 by ghostdog74 on Friday 21st of December 2007 07:32:35 AM
Old 12-21-2007
if you have GNU date
Code:
# date +%Y%m%d%H%M%S -d  "1 hour ago"
20071221193551

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

param as current date+time

Hi All, I need to pass param on aix "errpt -a -s MMDDHHMMYY -e MMDDHHMMYY". How do I read the date+time on the system and pass it as parameter? I need also the -s as previous day and the -e as current day. Thanks, itik (1 Reply)
Discussion started by: itik
1 Replies

2. Shell Programming and Scripting

How to find a date which is 7 days past when given current date

hii all. I have to get the date of the 7th day past from the current date. if i give the current date as sep 3 then i must get the date as 27th of august. can we get the values from the "cal" command. cal | awk '{print $2}' will this type of command work. actually my need is if today is... (17 Replies)
Discussion started by: ladtony
17 Replies

3. Shell Programming and Scripting

Compare file timestamp with current date. Diff must be 1 hour.

Hello, I've created the script below to compare the content of two files with a delay of an hour. After an hour, the lines that exist in both files, will be printed and executed. The script now uses a counter to countdown 50 minutes. But what I would prefer is to check the file timestamp of... (3 Replies)
Discussion started by: taipan
3 Replies

4. Shell Programming and Scripting

Date One Week Ago From Given Date, Not From Current Date

Hi all, I've used various scripts in the past to work out the date last week from the current date, however I now have a need to work out the date 1 week from a given date. So for example, if I have a date of the 23rd July 2010, I would like a script that can work out that one week back was... (4 Replies)
Discussion started by: Donkey25
4 Replies

5. Shell Programming and Scripting

How far is given date from current time?

give a date and time: Jun 12 21:05:16 06-12-2012 21:05:16 2012/06/12 21:05:16 How can i subtract these dates and times from the current date and time and get back the difference in seconds? a one liner like: echo "Jun 12 21:05:16" | some perl/awk programming 90900s (2 Replies)
Discussion started by: SkySmart
2 Replies

6. UNIX for Dummies Questions & Answers

Adding hours and minutes to current date (Only to date not to time)

Hi, I want to add some hours and minutes to the current date. For example, if the current date is "July 16, 2012 15:20", i want to add 5 hours 30 minutes to "July 16, 2012 00:00" not to "July 16, 2012 15:20". Please help. Thanks! (4 Replies)
Discussion started by: manojgarg
4 Replies

7. Shell Programming and Scripting

Displaying current date time of EDT in IST time

Hi Folks, My server time is in EDT. And i am sending automated mails from that server in which i need to display the current date time as per IST (GMT+5:30). Please advice how to display the date time as per IST. IST time leads 9:30 mins to EDT. and i wrote something like below. ... (6 Replies)
Discussion started by: Showdown
6 Replies

8. Shell Programming and Scripting

Add current date and time

i have file 1.txt asdas|csada|13|03|10|04|23|A1|canberra sdasd|sfdsf|13|04|26|23|28|A1|sydney i want to add today's date and time in the end of each row expected output asdas|csada|13|03|10|04|23|A1|canberra|130430|1358 sdasd|sfdsf|13|04|26|23|28|A1|sydney|130430|1358 todays date... (10 Replies)
Discussion started by: radius
10 Replies

9. Shell Programming and Scripting

Seven days past date from current date

hi all.. i want 2 know how 2 find 7days past date from current date.. when i used set datetime = `date '+%m%d%y'` i got 060613.. i just want to know hw to get 053013.. i tried using date functions but couldnt get it :( i use c shell and there is no chance that i can change that ..... (3 Replies)
Discussion started by: Rahul619
3 Replies

10. Shell Programming and Scripting

Need to substract date with current date and time

I have below file which contain the date in column 3,4,5 12345 open 10/10/13 10:08 PM 3 application is in java 67899 open 12/10/13 2:31 AM 2 apps can be reach 23456 open 11/9/13 2:31 AM 4 java is OK 65432 open 12/10/13 10:07 PM 9 we are... (1 Reply)
Discussion started by: vijay_rajni
1 Replies
GETDATE(3)						     Library Functions Manual							GETDATE(3)

NAME
getdate - convert time and date from ASCII SYNOPSIS
#include <sys/types.h> #include <sys/timeb.h> time_t getdate(buf, now) char *buf; struct timeb *now; DESCRIPTION
Getdate is a routine that converts most common time specifications to standard UNIX format. The first argument is the character string containing the time and date; the second is the assumed current time (used for relative specifications); if NULL is passed, ftime(2) is used to obtain the current time and timezone. The character string consists of 0 or more specifications of the following form: tod A tod is a time of day, which is of the form hh:mm[:ss] (or hhmm) [meridian] [zone]. If no meridian - am or pm - is specified, a 24-hour clock is used. A tod may be specified as just hh followed by a meridian. date A date is a specific month and day, and possibly a year. Acceptable formats are mm/dd[/yy] and monthname dd[, yy] If omitted, the year defaults to the current year; if a year is specified as a number less than 100, 1900 is added. If a number not followed by a day or relative time unit occurs, it will be interpreted as a year if a tod, monthname, and dd have already been specified; other- wise, it will be treated as a tod. This rule allows the output from date(1) or ctime(3) to be passed as input to getdate. day A day of the week may be specified; the current day will be used if appropriate. A day may be preceeded by a number, indicating which instance of that day is desired; the default is 1. Negative numbers indicate times past. Some symbolic numbers are accepted: last, next, and the ordinals first through twelfth (second is ambiguous, and is not accepted as an ordinal number). The symbolic number next is equivalent to 2; thus, next monday refers not to the immediately coming Monday, but to the one a week later. relative time Specifications relative to the current time are also accepted. The format is [number] unit; acceptable units are year, month, fort- night, week, day, hour, minute, and second. The actual date is formed as follows: first, any absolute date and/or time is processed and converted. Using that time as the base, day- of-week specifications are added; last, relative specifications are used. If a date or day is specified, and no absolute or relative time is given, midnight is used. Finally, a correction is applied so that the correct hour of the day is produced after allowing for daylight savings time differences. Getdate accepts most common abbreviations for days, months, etc.; in particular, it will recognize them with upper or lower case first let- ter, and will recognize three-letter abbreviations for any of them, with or without a trailing period. Units, such as weeks, may be speci- fied in the singular or plural. Timezone and meridian values may be in upper or lower case, and with or without periods. FILES
/usr/lib/libu.a SEE ALSO
ctime(3), time(2) AUTHOR
Steven M. Bellovin (unc!smb) Dept. of Computer Science University of North Carolina at Chapel Hill BUGS
Because yacc(1) is used to parse the date, getdate cannot be used a subroutine to any program that also needs yacc. The grammar and scanner are rather primitive; certain desirable and unambiguous constructions are not accepted. Worse yet, the meaning of some legal phrases is not what is expected; next week is identical to 2 weeks. The daylight savings time correction is not perfect, and can get confused if handed times between midnight and 2:00 am on the days that the reckoning changes. Because localtime(2) accepts an old-style time format without zone information, attempting to pass getdate a current time containing a dif- ferent zone will probably fail. unc GETDATE(3)
All times are GMT -4. The time now is 02:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy