By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,907 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,907 IT Pros & Developers. It's quick & easy.

date and time conversion to EPOCH seconds

P: n/a
Hi All,

I can convert a current time in time_t form to user understandable form
using the apis - time, gmtime and strftime.

How can i convert in the reverse way? ie take a time and date string in the
form "Thu, 21 Feb 2002 13:02:03 GMT" and convert into time_t seconds? Is
there any c library api available for accomplishing this?

Thanks in advance,

regards,
Rajmohan
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Rajmohan" <ra*******@yahoo.com> wrote in message news:be**********@newshost.mot.com...
Hi All,

I can convert a current time in time_t form to user understandable form
using the apis - time, gmtime and strftime.

How can i convert in the reverse way? ie take a time and date string in the
form "Thu, 21 Feb 2002 13:02:03 GMT" and convert into time_t seconds? Is
there any c library api available for accomplishing this?


You can convert the tm structure to the time_t value by using
mktime(); you can also do the time arithmetic with it. But there is
no standard function to convert a string to the time_t value or the
tm structure; some implementations provide a non-portable function for
that purpose as an extension. Use it if any, or make yours if none or
it doesn't taste to yours.
--
Jun, Woong (my******@hanmail.net)
Dept. of Physics, Univ. of Seoul

Nov 13 '05 #2

P: n/a
On Wed, 9 Jul 2003 17:48:51 +0530, in comp.lang.c , "Rajmohan"
<ra*******@yahoo.com> wrote:
Richard,

Thanks a lot. But none of the routines - strptime/partime/getdate are
available on Win32 platform. Could u please point to links for win32...


simplest way with a format like that would be to parse it yourself
into a struct tm. Should take about 30 mins to write the code, faster
than searching the web.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.