linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nanakos Chrysostomos" <nanakos@wired-net.gr>
To: "Lejanson C. Go" <lejanson@ntsp.nec.co.jp>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: time conversion
Date: Tue, 23 Aug 2005 10:42:55 +0300 (EEST)	[thread overview]
Message-ID: <56285.62.1.10.221.1124782975.squirrel@webmail.wired-net.gr> (raw)
In-Reply-To: <430AD085.7070004@hq.ntsp.nec.co.jp>

#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>

void print_time ()
{
        struct timeval tv;
        struct tm* ptm;
        char time_string[40];
        long milliseconds;

        gettimeofday (&tv, NULL);
        ptm = localtime (&tv.tv_sec);
        strftime (time_string, sizeof (time_string), "%Y-%m-%d %H:%M:%S",
ptm);
        milliseconds = tv.tv_usec / 1000;
        printf ("%s.%03ld\n", time_string, milliseconds);
}


main()
{
        print_time();
}

I hope this helps.



  reply	other threads:[~2005-08-23  7:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-23  7:30 time conversion Lejanson C. Go
2005-08-23  7:42 ` Nanakos Chrysostomos [this message]
2005-08-23 14:07 ` kranthi
  -- strict thread matches above, loose matches on Subject: below --
2005-08-24  2:21 Suma Choudhary

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56285.62.1.10.221.1124782975.squirrel@webmail.wired-net.gr \
    --to=nanakos@wired-net.gr \
    --cc=lejanson@ntsp.nec.co.jp \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).