Real time converted to Unix time

Discussion in 'Perl Misc' started by Brian, Aug 29, 2003.

  1. Brian

    Brian Guest

    I have seen many request to go from unix to GM time, but I have not
    seen the reverse. Anyone know what the formula would be to convert a
    US standard date format to unix time. The variable is something like
    08282003 for August 28th 2003. I was thinking that I take each set of
    numbers and multiply them by the number of seconds in that set. for
    example
    Each day = 86400 seconds - so for the above example, 2419200 seconds
    in 28 days.
    Each month... well - thats the mystery.
    Each year 31536000 seconds. But I think I am doing this wrong. Plus,
    there is probably a module out there that does it for me.

    Any and all help is very appreciated.
    Brian, Aug 29, 2003
    #1
    1. Advertising

  2. On 28 Aug 2003 17:04:36 -0700
    (Brian) wrote:
    > I have seen many request to go from unix to GM time, but I have not
    > seen the reverse. Anyone know what the formula would be to convert
    > a US standard date format to unix time. The variable is something
    > like 08282003 for August 28th 2003. I was thinking that I take each
    > set of numbers and multiply them by the number of seconds in that
    > set. for example
    > Each day = 86400 seconds - so for the above example, 2419200 seconds
    > in 28 days.
    > Each month... well - thats the mystery.
    > Each year 31536000 seconds. But I think I am doing this wrong.
    > Plus, there is probably a module out there that does it for me.
    >
    > Any and all help is very appreciated.


    There are several modules on CPAN that can convert time from one
    format to another. Plus, there are several time function built into
    Perl.

    Start with the documentation. The shell-ish way to convert and
    manipulate time is not a requirement in Perl - others have done the
    work for you.

    HTH

    --
    Jim
    James Willmore, Aug 29, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. senthil
    Replies:
    5
    Views:
    1,367
    senthil
    Jan 24, 2004
  2. Replies:
    12
    Views:
    1,618
    Dave Thompson
    Jan 10, 2005
  3. Curious Trigger
    Replies:
    2
    Views:
    1,802
    Curious Trigger
    Sep 9, 2006
  4. Replies:
    18
    Views:
    609
    Dave Thompson
    Jan 10, 2005
  5. Robert Wallace

    my own perl "dos->unix"/"unix->dos"

    Robert Wallace, Jan 21, 2004, in forum: Perl Misc
    Replies:
    7
    Views:
    268
    Michele Dondi
    Jan 22, 2004
Loading...

Share This Page