This removes the necessity to use an external program (nawk, perl) and makes only use of standard (ksh-)features. Anyways, i am glad you have a solution that works.
I hope this helps.
bakunin
Hi bakunin,
The date +%T output gives you hours, minutes, and seconds (on a 24 hour clock) since midnight in the current timezone. The desired date +%s (which is not available on many UNIX systems, including AIX) gives you seconds since the Epoch (midnight at the start of January 1, 1970 UCT). You need a lot more information than what is provided by the current 24 hour clock time to convert that output to seconds since the Epoch.
hi all UNIX Gurus,
this is my first post...so i posting this with great expectations:o...hoping to get the similar replies...
my question is....
need to get timestamp with millisecond in UNIX. Date command gives Year,month day, hour,minute and second but it does not give millisecond.
Any... (5 Replies)
Hi,
In unix the command "date +%s" displays the date-time in seconds since â00:00:00 1970-01-01 UTCâ (a GNU extension)
when executed on unix:
-sh-2.05b$ date +%s
1152092690
I tried with all the format control output but unable to display the date-time in seconds i,e as in unix format. Can... (6 Replies)
It is required to calculate time difference in seconds between epoch time (19700101 00:00:00) and any given date time (e.g. 20010214 14:30:30).
Is there any command in unix to get it? Thanks in adv. (1 Reply)
Hi All,
Cany any one help me in solving this..
Problem statement: I have a requirement to find the time from which there are no files created in a given directory. For this I am assuming that I need to get the file creation time in seconds, then the current time in seconds using `date +%s`.... (7 Replies)
hi guys,
i need to know how to get the current date/time in seconds and i want to be able to do this in a one liner. like say for instance, if want to get what the time is right now, i'll issue a command like this:
## perl -e ' print scalar(localtime(time + 0)), "\n"'
Tue Jul 13 17:45:50... (4 Replies)
I am trying to get the ellapsed time in seconds in the body of the awk script. I use unix date to get the time. It works in BEGIN {} but not in the body {} of awk. Any ideas?
$ cat a
BEGIN {
"date +%s" | getline x
print x
}
{
"date +%s" | getline y
print y
}
$ echo "one line" |... (3 Replies)
I use this command to get the time elapsed for a process
ps -eo pid,pcpu,pmem,user,args,etime,cmd --sort=start_time | grep perl
It gives in format
19990 0.0 0.0 user /usr/bin/php 5-09:58:51 /usr/bin/php
I need in seconds.
Please use CODE tags for sample input and output as well... (2 Replies)
I have a list of time spans in seconds, and want to compute the time span
as hh:mm:nn
I am coding in bash and have coded the following. However, the results are
wrong as "%.0f" rounds the values.
Example:
ftm: 25793.5
tmspan(hrs,min,sec): 7.16 429.89 25793.50
hh: 7
mm: 10
ss:... (2 Replies)
Discussion started by: kristinu
2 Replies
LEARN ABOUT MOJAVE
time::seconds
Time::Seconds(3pm) Perl Programmers Reference Guide Time::Seconds(3pm)NAME
Time::Seconds - a simple API to convert seconds to other date values
SYNOPSIS
use Time::Piece;
use Time::Seconds;
my $t = localtime;
$t += ONE_DAY;
my $t2 = localtime;
my $s = $t - $t2;
print "Difference is: ", $s->days, "
";
DESCRIPTION
This module is part of the Time::Piece distribution. It allows the user to find out the number of minutes, hours, days, weeks or years in a
given number of seconds. It is returned by Time::Piece when you delta two Time::Piece objects.
Time::Seconds also exports the following constants:
ONE_DAY
ONE_WEEK
ONE_HOUR
ONE_MINUTE
ONE_MONTH
ONE_YEAR
ONE_FINANCIAL_MONTH
LEAP_YEAR
NON_LEAP_YEAR
Since perl does not (yet?) support constant objects, these constants are in seconds only, so you cannot, for example, do this: "print
ONE_WEEK->minutes;"
METHODS
The following methods are available:
my $val = Time::Seconds->new(SECONDS)
$val->seconds;
$val->minutes;
$val->hours;
$val->days;
$val->weeks;
$val->months;
$val->financial_months; # 30 days
$val->years;
$val->pretty; # gives English representation of the delta
The usual arithmetic (+,-,+=,-=) is also available on the objects.
The methods make the assumption that there are 24 hours in a day, 7 days in a week, 365.24225 days in a year and 12 months in a year.
(from The Calendar FAQ at http://www.tondering.dk/claus/calendar.html)
AUTHOR
Matt Sergeant, matt@sergeant.org
Tobias Brox, tobiasb@tobiasb.funcom.com
BalXzs SzabX (dLux), dlux@kapu.hu
LICENSE
Please see Time::Piece for the license.
Bugs
Currently the methods aren't as efficient as they could be, for reasons of clarity. This is probably a bad idea.
POD ERRORS
Hey! The above document had some coding errors, which are explained below:
Around line 245:
Non-ASCII character seen before =encoding in 'BalXzs'. Assuming UTF-8
perl v5.18.2 2014-01-06 Time::Seconds(3pm)