Perl ::duration of time in between dates


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl ::duration of time in between dates
# 1  
Old 06-11-2013
Perl ::duration of time in between dates

Hello All,

I have two strings with date and time as follows..

Code:
$starttime= "06/11/2013 ";
$starttime= "05:15";
$enddate="06/12/2013";
$endtime="04:45";

dates are in mm/dd/yyyy format and time in military format.
and I am looking the duration of time(in minutes) in between dates.

Could anyone please let me know the logic behind this?

Thanks in advance....
# 2  
Old 06-11-2013
Probably split dd, mm, yyyy, hr,min,sec and use DateTime module to get the difference in duration.

DateTime - search.cpan.org

Thanks
-Raja
# 3  
Old 06-11-2013
Code:
startdate="06/11/2013"
starttime="05:15"
enddate="06/12/2013"
endtime="04:45"

Code:
echo $((($(date -d "$enddate $endtime" +%s) - $(date -d "$startdate $starttime" +%s))/60))
1410

# 4  
Old 06-11-2013
The standard Time::Local module is sufficient for your purpose.
Look at its man page for details.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to calculate time duration in Linux?

I want to calculate duration for below file in this format SID | Date | Starttime |Date |End time 1607 |2019-04-05|13:06:42|2019-04-05|13:07:12 2327 |2019-04-05|13:57:26|2019-04-05|13:57:43 O/p should be like this: SID | Date | Starttime |Date |Endtime... (4 Replies)
Discussion started by: anupmishra
4 Replies

2. UNIX for Dummies Questions & Answers

How to list files for particular duration of time .?

Hi there is a lot of file dated from last week till ofpresent date. if i want to list only last 3 days files using ls command how can i do it please suggest. below is the list of the file. and i want to list files from MAy 12 to May 16. Nov 22 2011 NSSM.UPPLSCPLB81 Jan 12... (2 Replies)
Discussion started by: scriptor
2 Replies

3. Shell Programming and Scripting

Calculate time difference between pst and pdt dates in perl

Hi, how to calculate the time difference between PST date and PDT date in perl scripting. date1: Mon Dec 31 16:00:01 PST 2015 date2: Tue Mar 19 06:09:30 PDT 2013 and also difference between PST-PST and PDT-PDT need difference in months or days (months prefereble). (3 Replies)
Discussion started by: praveen265
3 Replies

4. Shell Programming and Scripting

Getting the Start, End time and duration using date command

Oracle Enterprise Linux We want to track how long a process takes to complete its execution. This is what we want in the schell script Before the process is started , get the time with date, hours and minutes execute the process After the process has ended , get the time with date,... (5 Replies)
Discussion started by: omega3
5 Replies

5. Shell Programming and Scripting

Calculating the epoch time from standard time using awk and calculating the duration

Hi All, I have the following time stamp data in 2 columns Date TimeStamp(also with milliseconds) 05/23/2012 08:30:11.250 05/23/2012 08:30:15.500 05/23/2012 08:31.15.500 . . etc From this data I need the following output. 0.00( row1-row1 in seconds) 04.25( row2-row1 in... (5 Replies)
Discussion started by: ks_reddy
5 Replies

6. UNIX for Advanced & Expert Users

time duration of being online of a particular user given the user name

in a multi user system of 3 users X,Y,Z, if i know that X is presently online, is it possible to determine for how long has he been online? i mean the time duration (3 Replies)
Discussion started by: arindamlive
3 Replies

7. Shell Programming and Scripting

How to get time duration between two human readable time stamp in Unix?

Here is two time I have: Jul 12 16:02:01 Jul 13 01:02:01 and how can I do a simple match to get difference between two time which is 09:00:00 Thanks in advance. (3 Replies)
Discussion started by: ford99
3 Replies

8. HP-UX

Time Between Dates

Time Between Dates Does anyone know how to figure out the time between two dates, by reading two log files start.log(starting time) and end.log(ending time)? So if I have the content of start.log as : Mon, Feb 18, 2008 09:30:02 PM & end.log as: Tue, Feb 19, 2008 01:25:14 AM How can... (2 Replies)
Discussion started by: Sreejith_VK
2 Replies

9. Shell Programming and Scripting

Time Between Dates

Time Between Dates Does anyone know how to figure out the time between two dates in HP-UX, by reading two log files start.log(starting time) and end.log(ending time)? So if I have the content of start.log as : Mon, Feb 18, 2008 09:30:02 PM & end.log as: Tue, Feb 19, 2008 01:25:14 AM ... (3 Replies)
Discussion started by: Sreejith_VK
3 Replies

10. Solaris

Finding list of modified files for a particular time duration

Hi , I am trying to find out the List of files modified or added aftter installation of any component on SUN solaris box . But i am not able to do it using ls or find command . Can somebody help me out ? Thanks Sanjay Gupta (2 Replies)
Discussion started by: sanajyg_mnit
2 Replies
Login or Register to Ask a Question