I am a newbie in shell scripting, hope you can advice how can I compare the date/time of file extracted from 'll' and current system date/time.
I have done the following:
ll -rt > $FILE_AGE_LOG
FILE_DATETIME=`more $FILE_AGE_LOG | head -02 | cut -c 45-57`
It returns 'May 4 19:11'.
If I... (4 Replies)
I need to extract the date part from the file name (20080221 in this ex) and compare it with the current date and delete it, if it is a past date.
$file = exp_ABCD4_T-2584780_upto_20080221.dmp.Z
really appreciate any help.
thanks
mkneni (4 Replies)
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)
Hello gurus,
I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4:
NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
I'm trying to get the date output to be in the form yyyy-mm-dd (e.g. 2013-01-18)
!/bin/sh
modDate=$(stat -c %y $1)
echo $modDate >> $1
When I run this on another file (by typing ./dateScript theFile.txt), I keep getting this message:
stat: illegal option -- c
What's wrong with my code... (2 Replies)
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)
We want to call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below:
abc.txt
------------------
Code:
line1
line2
line3
$$EDWS_DATE_INSERT=08-27-2019
line4
$$EDWS_PREV_DATE_INSERT=08-26-2019
I am trying to write a... (3 Replies)
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
LEARN ABOUT PHP
datetime.settime
DATETIME.SETTIME(3) 1 DATETIME.SETTIME(3)DateTime::setTime - Sets the time
Object oriented style
SYNOPSIS
public DateTime DateTime::setTime (int $hour, int $minute, [int $second])
DESCRIPTION
Procedural style
DateTime date_time_set (DateTime $object, int $hour, int $minute, [int $second])
Resets the current time of the DateTime object to a different time.
PARAMETERS
o $object
-Procedural style only: A DateTime object returned by date_create(3). The function modifies this object.
o $hour
- Hour of the time.
o $minute
- Minute of the time.
o $second
- Second of the time.
RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.0 | |
| | |
| | Changed the return value on success from NULL to |
| | DateTime. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
DateTime.setTime(3) example
Object oriented style
<?php
$date = new DateTime('2001-01-01');
$date->setTime(14, 55);
echo $date->format('Y-m-d H:i:s') . "
";
$date->setTime(14, 55, 24);
echo $date->format('Y-m-d H:i:s') . "
";
?>
Procedural style
<?php
$date = date_create('2001-01-01');
date_time_set($date, 14, 55);
echo date_format($date, 'Y-m-d H:i:s') . "
";
date_time_set($date, 14, 55, 24);
echo date_format($date, 'Y-m-d H:i:s') . "
";
?>
The above examples will output something similar to:
2001-01-01 14:55:00
2001-01-01 14:55:24
Example #2
Values exceeding ranges are added to their parent values
<?php
$date = new DateTime('2001-01-01');
$date->setTime(14, 55, 24);
echo $date->format('Y-m-d H:i:s') . "
";
$date->setTime(14, 55, 65);
echo $date->format('Y-m-d H:i:s') . "
";
$date->setTime(14, 65, 24);
echo $date->format('Y-m-d H:i:s') . "
";
$date->setTime(25, 55, 24);
echo $date->format('Y-m-d H:i:s') . "
";
?>
The above example will output:
2001-01-01 14:55:24
2001-01-01 14:56:05
2001-01-01 15:05:24
2001-01-02 01:55:24
SEE ALSO DateTime.setDate(3), DateTime.setISODate(3).
PHP Documentation Group DATETIME.SETTIME(3)