From: "Suma Choudhary" <sumac@myw.ltindia.com>
To: lejanson@ntsp.nec.co.jp, nanakos@wired-net.gr
Cc: linux-c-programming@vger.kernel.org
Subject: Re: time conversion
Date: Wed, 24 Aug 2005 07:51:44 +0530 [thread overview]
Message-ID: <s30c2716.024@EMAIL> (raw)
Hi
How about using time() and ctime() functions.
regards
suma
>>> "Nanakos Chrysostomos" <nanakos@wired-net.gr> 08/23/05 13:09 PM >>>
#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.
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2005-08-24 2:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-24 2:21 Suma Choudhary [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-08-23 7:30 time conversion Lejanson C. Go
2005-08-23 7:42 ` Nanakos Chrysostomos
2005-08-23 14:07 ` kranthi
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=s30c2716.024@EMAIL \
--to=sumac@myw.ltindia.com \
--cc=lejanson@ntsp.nec.co.jp \
--cc=linux-c-programming@vger.kernel.org \
--cc=nanakos@wired-net.gr \
/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).