From: Sumit Narayan <talk2sumit@gmail.com>
To: jonathan@jonmasters.org
Cc: szonyi calin <caszonyi@yahoo.com>,
Ankit Jain <ankitjain1580@yahoo.com>,
linux prg <linux-c-programming@vger.kernel.org>
Subject: Re: Unix Time
Date: Mon, 27 Sep 2004 17:33:57 -0400 [thread overview]
Message-ID: <1458d96104092714337dbd101b@mail.gmail.com> (raw)
In-Reply-To: <35fb2e59040927045735974a2a@mail.gmail.com>
You can use ctime() for conversion.
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main(){
time_t a;
printf("%d = ", time(&a));
printf("%s\n", ctime(&a));
return 0;
}
Hope this helps.
--Sumit
On Mon, 27 Sep 2004 12:57:42 +0100, Jon Masters <jonmasters@gmail.com> wrote:
> On Mon, 27 Sep 2004 12:59:47 +0200 (CEST), szonyi calin
> <caszonyi@yahoo.com> wrote:
>
> > to convert a number of secconds in actual time:
> > a minute has 60 seconds
> > an hour has 60 minutes = 3600 seconds
> > a day has 24 hours = 86400 seconds
>
> ...but don't use this because over the period of seconds since epoch
> (January 1 1970 is when UNIX began counting time) it'll not take in to
> account leap seconds and the like - so you'll cunningly be out of time
> by a little in every calculation.
>
> No. Use the standard POSIX time functions instead - e.g. localtime()
> to give you the view of time for where you are in the world.
>
> Cheers,
>
> Jon.
>
>
> -
> 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
>
prev parent reply other threads:[~2004-09-27 21:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-26 14:02 Unix Time Ankit Jain
2004-09-27 3:01 ` Suciu Flavius
2004-09-26 22:57 ` Jon Masters
2004-09-27 5:10 ` Ankit Jain
2004-09-27 10:59 ` szonyi calin
2004-09-27 11:57 ` Jon Masters
2004-09-27 21:33 ` Sumit Narayan [this message]
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=1458d96104092714337dbd101b@mail.gmail.com \
--to=talk2sumit@gmail.com \
--cc=ankitjain1580@yahoo.com \
--cc=caszonyi@yahoo.com \
--cc=jonathan@jonmasters.org \
--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).