Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Timestamp difference calculation

by swami (Initiate)
on Oct 07, 2012 at 19:30 UTC ( [id://997702]=perlquestion: print w/replies, xml ) Need Help??

swami has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I was trying to calculate the time difference b/w two input timestamp in perl. But i am not getting the value. Should i do any formatting of input paramters.
#!/usr/bin/perl use POSIX; my $ts1 = "$ARGV[0]"; my $ts2 = "$ARGV[1]"; $diff = ($ts1 - $ts2); print int($diff);

Replies are listed 'Best First'.
Re: Timestamp difference calculation
by kcott (Archbishop) on Oct 07, 2012 at 20:33 UTC

    G'day swami,

    Welcome to the monastery.

    You'll need to show us your input as well as the actual and expected output. Guidelines for this are given in: How do I post a question effectively?

    There are lots of date-related modules on CPAN; for instance, Date::Calc might be appropriate for your needs.

    -- Ken

Re: Timestamp difference calculation
by choroba (Cardinal) on Oct 07, 2012 at 20:20 UTC
    Hello swami, welcome to the Monastery.

    Please, wrap your code sample into <code> ... </code> tags. See Markup in the Monastery.

    What is the expected format of the input? Plese, show example input and expected output.

    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Timestamp difference calculation
by 2teez (Vicar) on Oct 07, 2012 at 20:22 UTC
    Hi,

    "... I was trying to calculate the time difference b/w two input timestamp in perl..."
    Please, I don't see how you are doing that here.
    However, in the first place, you might want to properly placed your script in code tags see How do I post a question effectively?
    Then, in the code you posted, I believe you intented $ARGV[1] NOT $ARGV1

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://997702]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-24 21:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found