time-t Questions
4
Does anyone know how to go from an ISO-8601-formatted date/time string to a time_t?
I am using C++ and it needs to work on Windows and Mac.
I have written the code but I am sure there is a version...
4
What I would like to do with my simple program is to calculate a difference in seconds between two dates.
time_t referenceDate;
time_t dateNow = time(0);
struct tm referenceDateComponent = {0};
re...
7
Solved
I have the following integers:
int y, mon, d, h, min, s;
Their values are: 2012, 06, 27, 12, 47, 53 respectively. I want to represent the date time of "2012/06/27 12:47:53 UTC" if I have selecte...
0
I'm trying to port my 32-bit ARM architecture to 64-bit time values.
Reading the answers from 64-bit time_t in Linux Kernel it tells me the following:
All user space must be compiled with a 64-bit...
Senseless asked 8/6, 2021 at 8:24
11
Solved
I want to get the current time of my system. For that I'm using the following code in C:
time_t now;
struct tm *mytime = localtime(&now);
if ( strftime(buffer, sizeof buffer, "%X", myti...
5
Solved
Is there any C++ implementation of 64-bit Unix timestamp conversions for 32-bit systems? I need to convert struct tm to 64-bit integer and vice versa, including leap years, time zones, UTC. Also ne...
Ellsworthellwood asked 27/10, 2011 at 10:1
2
I have compiled kernel 3.19.1 but still have a problem with time_t. Just a simple program with cout << sizeof (time_t); gives size of 4 bytes, not 8 bytes as was my intention.
Should I switch...
6
Solved
I'm doing a lot of calculations with times, building time objects relative to other time objects by adding seconds. The code is supposed to run on embedded devices and servers. Most documentations ...
5
Solved
On Windows I can call:
_time32(__time32_t); // to get 32-bit time_t
_time64(__time64_t); // to get 64-bit time_t
(both in 32 and 64-bit programs)
Is there any way do this in Linux (compiling wi...
4
Solved
I want to convert a UTC date & time given in numbers for year, month, day, etc. to a time_t. Some systems offer functions like mkgmtime or timegm for this purpose but that is not standard and d...
4
Solved
I have some code which is built both on Windows and Linux. Linux at this point is always 32-bit but Windows is 32 and 64-bit. Windows wants to have time_t be 64-bit and Linux still has it as ...
Zinkenite asked 18/3, 2010 at 3:39
2
Solved
I have a double containing seconds. I would like to convert this into a time_t.
I can't find a standard function which accomplishes this. Do I have to fill out the time_t by hand?
Lorileelorilyn asked 23/6, 2015 at 10:31
2
Solved
time_t now = time(0);
std::string h = std::string (ctime (&now));
std::cout << "\nh: " << h;
Current output that I am receiving is: Thu Sep 14 10:58:26 2017
I want the output a...
Jorgejorgensen asked 14/9, 2017 at 5:34
4
I have one struct tm.
And I need to add some fixed interval (given in xx years, xx months, xx days)
to the tm struct.
Is there any standard function to do this?
The compiler I use is MSVC 2005 on ...
3
Solved
I am once again going from Windows to Linux, I have to port a function from Windows to Linux that calculates NTP time. Seems simple but the format is in Windows FILETIME format. I sort of have an i...
Copley asked 27/8, 2010 at 15:15
1
Solved
I have an array of time here:
struct cl{
unsigned char *buffer;
time_t t = time(0);
struct tm * ct = localtime(&t);
};
and then:
cl sadi[10];
But for example I got sadi[5] at 21:58,...
4
Solved
I want to make my code more platform-/implementation-independent. I don't know what a time_t will be implemented as on the platform when the code is being compiled. How do I know the type of t to d...
4
Solved
I have some code that uses the Oracle function add_months to increment a Date by X number of months.
I now need to re-implement the same logic in a C / C++ function. For reasons I don't want/need ...
4
Solved
I am writing some code that will run on multiple intercommunicating systems. I was using time() to get time_t, but this was causing problems with time zone differences between the systems, so I wan...
3
Solved
My purpose is to execute a while loop for a defined time (e.g. 90 seconds for this example). It does not have to be exactly 90 s, but 1-2 second inaccuracy is acceptable. I trued to use clock()` fu...
4
Solved
I do not know the data type of time_t. Is it a float double or something else? Because if I want to display it I need the tag that corresponds with it for printf. I can handle the rest from t...
1
Solved
I have a variable which uses time_t data type. I would like to convert this type into "YYYY-MM-DD HH:MM:SS". I only know that it works in localtime() per this example:
char buff[20];
time...
2
Solved
I have 2 variables of type time_t - varEnd and varStart.
Now in order to see the difference between them
Either I can do
varEnd - varStart;
or
difftime(varEnd, varStart);
and both returns ...
3
Solved
What is the difference between clock_t, time_t and struct tm?
struct tm looks like this:
struct tm{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_...
2
Solved
I want to extract hours, minutes and seconds as integer values from a time_t value representing seconds since epoch.
The value for hours is not correct. Why?
#include <stdio.h>
#include &l...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.