Sponsored Content
Top Forums Shell Programming and Scripting Time in seconds on AIX 4.3.2.0 Post 302992575 by bakunin on Monday 27th of February 2017 12:23:32 PM
Old 02-27-2017
Quote:
Originally Posted by Don Cragun
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).
I am well aware of the difference between epoch time and seconds since midnight. I was (see post #1) - and perhaps erroneously so - convinced that thread-o/p was looking for the seconds since midnight ("time in seconds"), not the epoch (from which the seconds since midnight can be derived too, with some effort). So i offered this as a perceived shortcut.

date +'%s' is, btw., available on (a recent) AIX, but probably not on AIX 4.3.2 (which, IIRC, should be around 1997 or 1998).

bakunin

Last edited by bakunin; 02-27-2017 at 01:28 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

getting time in mili seconds

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)
Discussion started by: Bhups
5 Replies

2. AIX

Unable to display the date-time in seconds on AIX

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)
Discussion started by: me_haroon
6 Replies

3. Shell Programming and Scripting

how to display time in minutes n seconds...

Hi all, may i know how to display time in minutes and seconds(may be milliseconds and even smaller that ) in shell scripts.... (1 Reply)
Discussion started by: santy
1 Replies

4. UNIX for Advanced & Expert Users

Time Difference in seconds

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)
Discussion started by: k_bijitesh
1 Replies

5. Shell Programming and Scripting

File creation time in seconds

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)
Discussion started by: chary
7 Replies

6. Shell Programming and Scripting

Time difference in seconds

date1=$(date +"%H:%M:%S") date2=$(date +"01:00:54") diff=$date2-$date1 echo $diff How to get the time difference in seconds. (4 Replies)
Discussion started by: sandy1028
4 Replies

7. Shell Programming and Scripting

Get Current Time in Seconds Perl

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)
Discussion started by: SkySmart
4 Replies

8. Shell Programming and Scripting

Elapsed time in seconds in awk

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)
Discussion started by: arturas123
3 Replies

9. Shell Programming and Scripting

Get how much time process has been running in seconds

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)
Discussion started by: anil510
2 Replies

10. Shell Programming and Scripting

Converting seconds to time

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
DateTime::Format::Epoch(3pm)				User Contributed Perl Documentation			      DateTime::Format::Epoch(3pm)

NAME
DateTime::Format::Epoch - Convert DateTimes to/from epoch seconds SYNOPSIS
use DateTime::Format::Epoch; my $dt = DateTime->new( year => 1970, month => 1, day => 1 ); my $formatter = DateTime::Format::Epoch->new( epoch => $dt, unit => 'seconds', type => 'int', # or 'float', 'bigint' skip_leap_secondss => 1, start_at => 0, local_epoch => undef, ); my $dt2 = $formatter->parse_datetime( 1051488000 ); # 2003-04-28T00:00:00 $formatter->format_datetime($dt2); # 1051488000 DESCRIPTION
This module can convert a DateTime object (or any object that can be converted to a DateTime object) to the number of seconds since a given epoch. It can also do the reverse. METHODS
o new( ... ) Constructor of the formatter/parser object. It can take the following parameters: "epoch", "unit", "type", "skip_leap_seconds", "start_at", "local_epoch" and "dhms". The epoch parameter is the only required parameter. It should be a DateTime object (or at least, it has to be convertible to a DateTime object). This datetime is the starting point of the day count, and is usually numbered 0. If you want to start at a different value, you can use the start_at parameter. The unit parameter can be "seconds", "milliseconds, "microseconds" or "nanoseconds". The default is "seconds". If you need any other unit, you must specify the number of units per second. If you specify a number of units per second below 1, the unit will be longer than a second. In this way, you can count days: unit => 1/86_400. The type parameter specifies the type of the return value. It can be "int" (returns integer value), "float" (returns floating point value), or "bigint" (returns Math::BigInt value). The default is either "int" (if the unit is "seconds"), or "bigint" (if the unit is nanoseconds). The default behaviour of this module is to skip leap seconds. This is what (most versions of?) UNIX do. If you want to include leap seconds, set skip_leap_seconds to false. Some operating systems use an epoch defined in the local timezone of the computer. If you want to use such an epoch in this module, you have two options. The first is to submit a DateTime object with the appropriate timezone. The second option is to set the local_epoch parameter to a true value. In this case, you should submit an epoch with a floating timezone. The exact epoch used in "format_datetime" will then depend on the timezone of the object you pass to "format_datetime". Most often, the time since an epoch is given in seconds. In some circumstances however it is expressed as a number of days, hours, minutes and seconds. This is done by NASA, for the so called Mission Elapsed Time. For example, 2/03:45:18 MET means it has been 2 days, 3 hours, 45 minutes, and 18 seconds since liftoff. If you set the dhms parameter to true, format_datetime returns a four element list, containing the number of days, hours, minutes and seconds, and parse_datetime accepts the same four element list. o format_datetime($datetime) Given a DateTime object, this method returns the number of seconds since the epoch. o parse_datetime($secs) Given a number of seconds, this method returns the corresponding DateTime object. BUGS
I think there's a problem when you define a count that does not skip leap seconds, and uses the local timezone. Don't do that. SUPPORT
Support for this module is provided via the datetime@perl.org email list. See http://lists.perl.org/ for more details. AUTHOR
Eugene van der Pijll <pijll@gmx.net> COPYRIGHT
Copyright (c) 2003-2006 Eugene van der Pijll. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
DateTime datetime@perl.org mailing list perl v5.10.1 2007-12-03 DateTime::Format::Epoch(3pm)
All times are GMT -4. The time now is 04:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy