473,789 Members | 2,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

date and time conversion to EPOCH seconds

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
2 13369

"Rajmohan" <ra*******@yaho o.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******@hanma il.net)
Dept. of Physics, Univ. of Seoul

Nov 13 '05 #2
On Wed, 9 Jul 2003 17:48:51 +0530, in comp.lang.c , "Rajmohan"
<ra*******@yaho o.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.c om/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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4599
by: Dan E. | last post by:
Hi all. I have a number the is the number of seconds from 1/1/1970. Is there a function in VB that will convert it to some thing more readable? some ting similar to time_t in c++ Thanks Dan...
2
5073
by: Peter Kleiweg | last post by:
Is there a safe and clean way to parse a date/time string into seconds since epoch? I have a string with date and time in GMT. I can get the correct value using this: #!/usr/bin/env python import os os.environ = 'UTC'
21
11090
by: Javier | last post by:
Hi I´ve a routine that will read date and times in a vector of strings ie: 30/02/2005 19:20 In some moment I´ll need to check if there are in vector a date like current date with a time >= current time and <= (current time + n minutes)
4
5824
by: flupke | last post by:
Is there an easy to convert following hour notation hh:mm to decimals? For instance 2 hours and 30 minutes as 2:30 to 2,50 I don't really know where to search for this kind of conversion. Thanks, Benedict
0
1524
by: Rob | last post by:
Hello, I get an date field as a part of download in the format 01 Mar 04 12:00:00. I want this to be converted as a short date.How do i proceed? Also not connected with the above but in the same table,i do a download and then compare it to a previous table and do a unmatched query.Whichever ID's do not match,I need to delete,but my delete query does not fire.The query is a simple one to one join of both the tables. Any suggestions?
3
2760
by: moni | last post by:
Hi, I wanted to convert a time value in the form of time_t into a readable form in C# or vice versa, in order to be able to subtract two time values and give the result in msecs. eg. I have a time value,
37
4693
by: David T. Ashley | last post by:
I have Red Hat Enterprise Linux 4. I was just reading up about UTC and leap seconds. Is it true on my system that the Unix time may skip up or down by one second at midnight when there is a leap second? By "Unix time" I mean the integer returned by time() and similar functions. I'm concerned about the "down" case. Some of the software I've written
1
983
by: Adith | last post by:
Hi, I have a date time coming into the system in the format YYYYMMDDHHmmSSFFF-ZZZZ. This is to be parsed to YYYYMMDDHHMMSS. How can i do this? Thanks in advance, Adith
0
16511
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any formatting considerations at all. They are simple, easy, and brief and you should use them any time you need to incorporate any date literals or date math in your T-SQL code. create function DateOnly(@DateTime DateTime) -- Returns @DateTime...
3
2025
by: mcgr0199 | last post by:
I have temperature data loggers that record temperature every 6 minutes for 120 days. When I upload the data to access the date/time field is automatically formatted from the data loggers to be in this format: 6/15/2009 12:06:00 AM. What I need to do with the data is look at certain time frames over the entire 120 day period (i.e. from 12pm to 9pm every day). How can I run a query to get just those times over that entire period? I've tried...
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10410
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.