Date integer - BSD

This is a discussion on Date integer - BSD ; Hi Everyone, Is there a Unix command to print the date as an integer? Thanks...

+ Reply to Thread
Results 1 to 8 of 8

Thread: Date integer

  1. Date integer

    Hi Everyone,

    Is there a Unix command to print the date as an integer?

    Thanks

  2. Re: Date integer

    E wrote:
    > Is there a Unix command to print the date as an integer?


    Yes.

    Look for the explanation of the "+-sign" in the date(1) manual page.

    - Philip

    --
    Philip Paeps Please don't email any replies
    philip@paeps.cx I follow the newsgroup.

    ptc1: you shall be first against the wall when the revolution comes

  3. Re: Date integer

    Philip Paeps wrote:
    +---------------
    | E wrote:
    | > Is there a Unix command to print the date as an integer?
    |
    | Yes.
    | Look for the explanation of the "+-sign" in the date(1) manual page.
    +---------------

    Which redirects one to "strftime(3)", where one finds "%s".


    -Rob

    -----
    Rob Warnock
    627 26th Avenue
    San Mateo, CA 94403 (650)572-2607


  4. Re: Date integer

    Rob Warnock wrote:
    > Philip Paeps wrote:
    > +---------------
    >| E wrote:
    >| > Is there a Unix command to print the date as an integer?
    >|
    >| Yes.
    >| Look for the explanation of the "+-sign" in the date(1) manual page.
    > +---------------
    >
    > Which redirects one to "strftime(3)", where one finds "%s".


    Yes.

    - Philip

    --
    Philip Paeps Please don't email any replies
    philip@paeps.cx I follow the newsgroup.

    Kitty: Yes, I watched 'Preaching to the Perverted'.
    I knew that film was sado-masochistic when I first noticed it was
    in NTSC format.

  5. Re: Date integer

    On Wed, 30 Jul 2008 10:58:36 UTC, E wrote:

    > Hi Everyone,
    >
    > Is there a Unix command to print the date as an integer?


    date "+%s"

    You didn't say what the integer had to represent - that one is seconds
    since the epoch.

    --
    Bob Eager
    UNIX since v6..
    http://tinyurl.com/2xqr6h


  6. Re: Date integer

    Bob Eager wrote:
    > On Wed, 30 Jul 2008 10:58:36 UTC, E wrote:
    >
    >> Hi Everyone,
    >>
    >> Is there a Unix command to print the date as an integer?

    >
    > date "+%s"
    >
    > You didn't say what the integer had to represent - that one is seconds
    > since the epoch.
    >


    I believe that is what I was looking for. The "%s" wasn't clear in the
    man page I was reading, but I found it.

    Thanks much
    Eric

  7. Re: Date integer

    Bob Eager wrote:
    > On Wed, 30 Jul 2008 10:58:36 UTC, E wrote:
    >
    >> Hi Everyone,
    >>
    >> Is there a Unix command to print the date as an integer?

    >
    > date "+%s"
    >
    > You didn't say what the integer had to represent - that one is seconds
    > since the epoch.
    >


    Is there a flag to also obtain the milliseconds?

    Eric

  8. Re: Date integer

    On Fri, 01 Aug 2008 11:03:58 -0400, Eric wrote:
    >
    > Is there a flag to also obtain the milliseconds?


    You get what's available as documented in strftime(3) -- as date(1)
    tells you. So if it's not in there, then no, it's not available.


    If you really need mili- or microseconds then you can get them through
    a small program in C or perl or whichever language you choose using the
    relevant system call[1], though program start/stop overhead means the
    numbers won't be accurate anyway.

    What do you need it for? There may be better approaches available.


    [1] gettimeofday(2) See also clocks(7) for more information about what
    sort of time counters are available.

    --
    j p d (at) d s b (dot) t u d e l f t (dot) n l .
    This message was originally posted on Usenet in plain text.
    Any other representation, additions, or changes do not have my
    consent and may be a violation of international copyright law.

+ Reply to Thread