If I'm reading MadeInGermany's code correctly, it is comparing YY/DD/MM HH:MM:SS instead of YY/MM/DD HH:MM:SS and is printing the more than 3 hours ago timestamps instead of the less than 3 hours old timestamps. As long as we're constructing strings to compare, I don't see the need to include the slashes in the dates and I'm also assuming that the minutes and seconds do have 2 digits with zero fill so I don't have to split the time fields (I just have to use leading 0 to fill an 8 character field to supply missing leading zeroes in the hour). And, I used FS instead of sub() and split() to split the date field.
I think RudiC left out a %S in the date format string, but on a 3 hour window, a difference of up to one minute might not be noticeable in the results.
I think this does what was requested (on systems where the date utility supports this form of -d option processing):
These 2 Users Gave Thanks to Don Cragun For This Post:
I'm trying to compare 2 dates between current time and the timestamp on a file.
The date format is mmdd
Both return Apr 1 but when using if statement
line 11: Apr 1: command not found error is returned
#!/bin/sh
log="DateLog"
Current_Date=`date +%b%e`
Filepmdate=`ls -l /file.txt |... (1 Reply)
Hello to all.
I work at AIX system without perl installed and I am restricted user, so I am limited to bash. In script that I am writing, I have to read line from file and transform date that I found inside to Unix timestamp. Line in file look something like this:
Tue Mar 29 06:59:00... (5 Replies)
I am doing this in my script ..
currenttimestamp=`db2 "select current timestamp from SYSIBM.SYSDUMMY1 with ur"`
echo s $currenttimestamp
but this is how its shows
s 1 -------------------------- 2011-04-18-12.43.25.345071 1 record(s) selected.
How can I just get the timestamp... (6 Replies)
Hi All,
I am new to unix programming. I am trying for a requirement and the requirement goes like this.....
I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
Hi,
In a field, I should receive the date with time stamp in a particular field. But sometimes the vendor sends just the date or the timestamp or correctl the date×tamp. I have to figure out the the data is a date or time stamp or date×tamp.
If it is date then append "<space>00:00:00"... (1 Reply)
I was looking at this script which outputs the two lines which differs less than one sec.
#!/usr/bin/perl -w
use strict;
use warnings;
use Time::Local;
use constant SEC_MILIC => 1000;
my $file='infile';
## Open for reading argument file.
open my $fh, "<", $file or die "Cannot... (1 Reply)
I have a file like this
-rwxr-xr-x 1 rewq other 168 Jan 13 07:05 check_files.sh
I want to compare (check_files.sh time) with the current time to see if its is older than 2 hours or not
if it is not older than 2 hrs then do something.can someone help me on this?.I dont... (7 Replies)
Hello ,
I am working on AIX. I have to convert Unix timestamp to normal timestamp. Below is the file. The Unix timestamp will always be preceded by
EFFECTIVE_TIME as first field as shown and there could be multiple EFFECTIVE_TIME in the file : 3.txt
Contents of... (6 Replies)
Hi Gurus,
I have a software which logs event in the log file and it has become to big to search into it.
I want to display all the lines from the log files between
<Jul 21, 2016 3:30:37 PM BST> to <Jul 21, 2016 3:45:37 PM BST>
that is 15 min data .
Please help
Use code tags, thanks. (10 Replies)
So basically I have a log file and each line in this log file starts with a timestamp:
MON DD HH:MM:SS
SEP 15 07:30:01
I need to grep all the lines between last hour timestamp and current timestamp. Then these lines will be moved to a tmp file from which I will grep for particular strings. ... (1 Reply)
Discussion started by: nms
1 Replies
LEARN ABOUT DEBIAN
image::exiftool::shift
Image::ExifTool::Shift(3pm) User Contributed Perl Documentation Image::ExifTool::Shift(3pm)NAME
Image::ExifTool::Shift.pl - ExifTool time shifting routines
DESCRIPTION
This module contains routines used by ExifTool to shift date and time values.
DETAILS
Time shifts are applied to standard EXIF-formatted date/time values (ie. "2005:03:14 18:55:00"). Date-only and time-only values may also
be shifted, and an optional timezone (ie. "-05:00") is also supported. Here are some general rules and examples to explain how shift
strings are interpreted:
Date-only values are shifted using the following formats:
'Y:M:D' - shift date by 'Y' years, 'M' months and 'D' days
'M:D' - shift months and days only
'D' - shift specified number of days
Time-only values are shifted using the following formats:
'h:m:s' - shift time by 'h' hours, 'm' minutes and 's' seconds
'h:m' - shift hours and minutes only
'h' - shift specified number of hours
Timezone shifts are specified in the following formats:
'+h:m' - shift timezone by 'h' hours and 'm' minutes
'-h:m' - negative shift of timezone hours and minutes
'+h' - shift timezone hours only
'-h' - negative shift of timezone hours only
A valid shift value consists of one or two arguments, separated by a space. If only one is provided, it is assumed to be a time shift when
applied to a time-only or a date/time value, or a date shift when applied to a date-only value. For example:
'7' - shift by 1 hour if applied to a time or date/time
value, or by one day if applied to a date value
'2:0' - shift 2 hours (time, date/time), or 2 months (date)
'5:0:0' - shift 5 hours (time, date/time), or 5 years (date)
'0:0:1' - shift 1 s (time, date/time), or 1 day (date)
If two arguments are given, the date shift is first, followed by the time shift:
'3:0:0 0' - shift date by 3 years
'0 15:30' - shift time by 15 hours and 30 minutes
'1:0:0 0:0:0+5:0' - shift date by 1 year and timezone by 5 hours
A date shift is simply ignored if applied to a time value or visa versa.
Numbers specified in shift fields may contain a decimal point:
'1.5' - 1 hour 30 minutes (time, date/time), or 1 day (date)
'2.5 0' - 2 days 12 hours (date/time), 12 hours (time) or
2 days (date)
And to save typing, a zero is assumed for any missing numbers:
'1::' - shift by 1 hour (time, date/time) or 1 year (date)
'26:: 0' - shift date by 26 years
'+:30 - shift timezone by 30 minutes
Below are some specific examples applied to real date and/or time values ('Dir' is the applied shift direction: '+' is positive, '-' is
negative):
Original Value Shift Dir Shifted Value
------------------------------- ---------------------
'20:30:00' '5' + '01:30:00'
'2005:01:27' '5' + '2005:02:01'
'11:54:00' '2.5 0' - '23:54:00'
'2005:11:02' '2.5 0' - '2005:10:31'
'2005:11:02 11:54:00' '2.5 0' - '2005:10:30 23:54:00'
'2004:02:28 08:00:00' '1 1.3' + '2004:02:29 09:18:00'
'07:00:00' '-5' + '07:00:00'
'07:00:00+01:00' '-5' + '07:00:00-04:00'
'07:00:00Z' '+2:30' - '07:00:00-02:30'
'1970:01:01' '35::' + '2005:01:01'
'2005:01:01' '400' + '2006:02:05'
'10:00:00.00' '::1.33' + '09:59:58.67'
NOTES
The format of the original date/time value is not changed when the time shift is applied. This means that the length of the date/time
string will not change, and only the numbers in the string will be modified. The only exception to this rule is that a 'Z' timezone is
changed to '+00:00' notation if a timezone shift is applied. A timezone will not be added to the date/time string.
TRICKY
This module is perhaps more complicated than it needs to be because it is designed to be very flexible in the way time shifts are specified
and applied...
The ability to shift dates by Y years, M months, etc, is somewhat contradictory to the goal of maintaining a constant shift for all time
values when applying a batch shift. This is because shifting by 1 month can be equivalent to anything from 28 to 31 days, and 1 year can
be 365 or 366 days, depending on the starting date.
The inconsistency is handled by shifting the first tag found with the actual specified shift, then calculating the equivalent time
difference in seconds for this shift and applying this difference to subsequent tags in a batch conversion. So if it works as designed,
the behaviour should be both intuitive and mathematically correct, and the user shouldn't have to worry about details such as this (in
keeping with Perl's "do the right thing" philosophy).
BUGS
This feature uses the standard time library functions, which typically are limited to dates in the range 1970 to 2038.
AUTHOR
Copyright 2003-2011, Phil Harvey (phil at owl.phy.queensu.ca)
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO Image::ExifTool(3pm)perl v5.12.4 2011-03-20 Image::ExifTool::Shift(3pm)