Sponsored Content
Top Forums Shell Programming and Scripting Getting the Start, End time and duration using date command Post 302724869 by Yoda on Thursday 1st of November 2012 11:43:57 AM
Old 11-01-2012
Code:
START_DATE=`date`
# Execute Process
END_DATE=`date`

echo "Job started at: $START_DATE"
echo "Job started at: $END_DATE"

sdt=$( date -d "$START_DATE" +%s )
edt=$( date -d "$END_DATE" +%s )

echo "$edt $sdt" | awk ' { printf("It took %.2f hours to complete this job.\n", ($1-$2)/60/60); } '

This User Gave Thanks to Yoda For This Post:
 

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Start time/end time and status of crontab job

Is there anyway to get the start time and end time / status of a crontab job which was just completed? Of course, we know the start time of the crontab job since we are scheduling. But I would like to know process start and time recorded somewhere or can be fetched from a command like 'ps'. ... (3 Replies)
Discussion started by: thambi
3 Replies

2. Shell Programming and Scripting

How to calculate time difference between start and end time of a process!

Hello All, I have a problem calculating the time difference between start and end timings...! the timings are given by 24hr format.. Start Date : 08/05/10 12:55 End Date : 08/09/10 06:50 above values are in mm/dd/yy hh:mm format. Now the thing is, 7th(08/07/10) and... (16 Replies)
Discussion started by: smarty86
16 Replies

3. Shell Programming and Scripting

Need to capture dates between start date and end date Using perl.

Hi All, Want to get all dates and Julian week number for that date between the start date and end date. How can I achive this using perl? (To achive above functionality, I was connecting to the database from DB server. Need to execute the same script in application server, since databse... (6 Replies)
Discussion started by: Nagaraja Akkiva
6 Replies

4. Shell Programming and Scripting

Extract week start,end date from given date in PERL

Hi All, what i want to do in perl is i should give the date at run time .Suppose date given is 23/12/2011(mm/dd/yyyy) the perl script shold find week start date, week end date, previous week start date,end date,next week start date, end date. In this case week start date will be-:12/19/2011... (2 Replies)
Discussion started by: parthmittal2007
2 Replies

5. UNIX for Dummies Questions & Answers

Print start date to end date, given $1 & $2 in ksh

Dear all, I have an user passing 2 parameter 31/03/2015 and 02/04/2015 to a ksh script. How to print the start date to end date. Expected output is : 31/03/2015 01/04/2015 02/04/2015 Note : 1. Im using aix and ksh 2. I have tried to convert the given input into a date, didnt... (0 Replies)
Discussion started by: mr.rajaravi
0 Replies

6. UNIX for Beginners Questions & Answers

Splitting week start date and end date based on custom period start dates

Below are my custom period start and end dates based on a calender, these dates are placed in a file, for each period i need to split into three weeks for each period row, example is given below. Could you please help out to achieve solution through shell script.. File content: ... (2 Replies)
Discussion started by: nani2019
2 Replies
DATETIME.SETTIMEZONE(3) 						 1						   DATETIME.SETTIMEZONE(3)

DateTime::setTimezone - Sets the time zone for the DateTime object

       Object oriented style

SYNOPSIS
public DateTime DateTime::setTimezone (DateTimeZone $timezone) DESCRIPTION
Procedural style DateTime date_timezone_set (DateTime $object, DateTimeZone $timezone) Sets a new timezone for a DateTime object. PARAMETERS
o $object -Procedural style only: A DateTime object returned by date_create(3). The function modifies this object. o $timezone - A DateTimeZone object representing the desired time zone. 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.setTimeZone(3) example Object oriented style <?php $date = new DateTime('2000-01-01', new DateTimeZone('Pacific/Nauru')); echo $date->format('Y-m-d H:i:sP') . " "; $date->setTimezone(new DateTimeZone('Pacific/Chatham')); echo $date->format('Y-m-d H:i:sP') . " "; ?> Procedural style <?php $date = date_create('2000-01-01', timezone_open('Pacific/Nauru')); echo date_format($date, 'Y-m-d H:i:sP') . " "; date_timezone_set($date, timezone_open('Pacific/Chatham')); echo date_format($date, 'Y-m-d H:i:sP') . " "; ?> The above examples will output: 2000-01-01 00:00:00+12:00 2000-01-01 01:45:00+13:45 SEE ALSO
DateTime.getTimezone(3), DateTimeZone.__construct(3). PHP Documentation Group DATETIME.SETTIMEZONE(3)
All times are GMT -4. The time now is 04:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy