Nothing wrong with the date solution -- you just need to run date one file at a time. (Use a for/while loop around ls -l). Meanwhile, perl's very handy to get the job done:
The perl command processes each line of input (with -n option) and for each line, $_ is the input line. "chop" removes the newline character at the end of the line. "stat" retrieves the inode data from the filename (in $_). "localtime" will spit out the date/time of the file using the local timezone. (Use "gmtime" if you want it to ignore timezone settings.)
Could someone tell me how to get the date/time (to the second) a file was last modified? I need to know if a file was modified in the last 30 seconds from the system date. I'm on AIX/unix 4.3 (3 Replies)
Hi All,
i have a time stamp. from that i am trying to awk to get the year, month and date.
TIME=20060614092446
DESIRED OUTPUT: 20060614
i am doing the following;
TIME=20060614092446
$ TimeStarted=`expr match '$TIME' '.*\(......\)'`
echo $TimeStarted
i am not getting... (2 Replies)
Hello all
This is a sample vmstat output ...
$ vmstat 2 2
kthr memory page disk faults cpu
r b w swap free re mf pi po fr de sr hx hx hx hx in sy cs us sy id
1 0 0 23105784 7810488 323 767 1742 5 5 0 0 0 0 0 0 683 780 457 43 ... (9 Replies)
How can I list the files in a directory and just show the file size, date stamp, timestamp and file name..
I've been trying to ls -lrt the directory to a file and then use the cut command but I'm not having any luck with getting the proper results.. I thought i could use the -f switch and count... (4 Replies)
Hi,
I have a file file1 having data as below
20110501,070742, ,012345678909,09999999999,68.5,
20110501,070236, ,089375855455,09376383333,374.3,
20110501,070525, ,090345895555,08444233444,206.2,
20110501,230051, ,000934744433,07624262223,480.1,
First field is date(YYYYMMDD) and second... (5 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)
Hi All,
Please read the below data carefully.
I need an unix command for converting unix timestamp to Epoch timestamp.
I need to daily convert this today's unix(UTC) time to epoch time, so i am thinking to make a shellscript for this.
Please help me for this by providing... (3 Replies)
Currently I am redirecting STDERR and STDOUT to a log file by doing the following
{
My KSH script contents
} 2>&1 | $DEBUGLOG
Problem is the STDERR & STDOUT do not have any date/time associated.
I want this to be something that i can embed into a script opposed to an argument I use... (4 Replies)
Hi,
I am running nohup cp & in a shell script.
How do I get a timestamp so I can get a timing of how long the copy took?
Roughly, the script does something like below:
date
nohup cp -rp /files/source /files/target &
date
I am mainly wanting to know how long it took for the... (9 Replies)
Hello,
I have files that with a naming convention as shown below. Some of the files have dates in the file name and some of them don't have dates in the file name.
imap-hp-import-20150917.txt
imap-dell-gec-import-20150901.txt
imap-cvs-import-20150915.txt
imap-gec-import.txt... (8 Replies)
Discussion started by: Saanvi1
8 Replies
LEARN ABOUT PHP
datetime.settimestamp
DATETIME.SETTIMESTAMP(3) 1 DATETIME.SETTIMESTAMP(3)DateTime::setTimestamp - Sets the date and time based on an Unix timestamp
Object oriented style
SYNOPSIS
public DateTime DateTime::setTimestamp (int $unixtimestamp)
DESCRIPTION
Procedural style
DateTime date_timestamp_set (DateTime $object, int $unixtimestamp)
Sets the date and time based on an Unix timestamp.
PARAMETERS
o $object
-Procedural style only: A DateTime object returned by date_create(3). The function modifies this object.
o $unixtimestamp
- Unix timestamp representing the date.
RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure.
EXAMPLES
Example #1
DateTime.setTimestamp(3) example
Object oriented style
<?php
$date = new DateTime();
echo $date->format('U = Y-m-d H:i:s') . "
";
$date->setTimestamp(1171502725);
echo $date->format('U = Y-m-d H:i:s') . "
";
?>
Procedural style
<?php
$date = date_create();
echo date_format($date, 'U = Y-m-d H:i:s') . "
";
date_timestamp_set($date, 1171502725);
echo date_format($date, 'U = Y-m-d H:i:s') . "
";
?>
The above examples will output something similar to:
1272508903 = 2010-04-28 22:41:43
1171502725 = 2007-02-14 20:25:25
NOTES
Using the Unix timestamp format to construct a new DateTime object is an alternative when using PHP 5.2, as shown in the example below.
Example #2
DateTime.setTimestamp(3) alternative in PHP 5.2
<?php
$ts = 1171502725;
$date = new DateTime("@$ts");
echo $date->format('U = Y-m-d H:i:s') . "
";
?>
The above example will output something similar to:
1171502725 = 2007-02-14 20:25:25
SEE ALSO DateTime.getTimestamp(3).
PHP Documentation Group DATETIME.SETTIMESTAMP(3)