`time_t` is a Standard-C data type to hold the seconds since UNIX epoch, that since the 1.1.1970.
Questions tagged [time-t]
171 questions
0
votes
2 answers
calculate difftime of two time-strings in c?
I have a file like this:
start 2020-01-13 02:43:39
ende 2020-01-13 02:44:26
start 2020-01-13 02:50:24
ende 2020-01-13 02:50:26
start 2020-01-13 02:50:24
ende 2020-01-13 02:50:26
Now Im trying to write a code which calculates the time difference…

robojames
- 1
- 3
0
votes
1 answer
How to convert a "%Y%m%d" format string into a time_t variable in C++?
I'm trying to convert strings into time_t variables. Here's the code I tried:
#include "pch.h"
#include
#include
#include
#include
using namespace std;
time_t String_to_timet1(string endDate) {
tm tm = {…

maynull
- 1,936
- 4
- 26
- 46
0
votes
1 answer
How to format time/date Strings from a time_t with unix time in C++
I have a time_t value from which I need to extract the values for year, month, dayOfMonth, hourOfDay, minute & second (as integers). If possible I'd like to minimize my reliance on libraries, but if there is a library function you can be reasonably…

Anju Maaka
- 263
- 1
- 10
0
votes
1 answer
Clock cycle of time_t and getting time problem
I am trying to get current raw time (the one that is NOT human readable) in my simple while loop. I searched time_t clock cycle period but I couldn't find any information about it.
1st issue: Does anyone know the clock cycle period of time_t in…

Deniz
- 378
- 3
- 16
0
votes
2 answers
Why is my second time_t variable not shown correctly
I would like to measure how long a particular operation takes, therefore I've written the following piece of code:
for (int counter2 = 0; counter2 <= 10; counter2++) { // I'll do the test 10 times,
…

Dominique
- 16,450
- 15
- 56
- 112
0
votes
1 answer
time_t and char* variable is unexpectedly getting overwritten
The following code
{
time_t t;
t = time(NULL);
char *A;
A = ctime(&t);
printf("%s -\n", A);
sleep(2);
time_t t1;
t1 = time(NULL);
printf("%s HERE A =\n", A);
char *B = ctime(&t1);
printf("%s HERE B =\n",…

raunaque patra
- 11
- 3
0
votes
2 answers
C++ - writing a scheduler with std::difftime - how to check for a time (HH:MM:SS) occurence during the day?
I try to have my program figure if an event is getting reached during the day
for instance, I want to be able to create events at 10:00:00 so that a task gets executed at that moment in the day (only once)
so I have this function that can tell the…

user7082181
- 354
- 3
- 15
0
votes
3 answers
Parsing user input using time_t
My idea is, if user enters t = 2.5, then I extract 2 and 0.5 separately in 2 different variables. But I am unable to do that.
Here is the code:
$ export LT_LEAK_START=1.5
$ echo $LT_LEAK_START
1.5
#include
#include
#include…

RajSanpui
- 11,556
- 32
- 79
- 146
0
votes
1 answer
Compareing tables in c and using clock problem
I have got problem with my obstacles, because when I try to compare possition of my object to possition of obstacle it is not working, I was trying something like that:
int x, y;
for(x=0; x<24; x++){
…

zimnykisiel
- 23
- 6
0
votes
1 answer
Problem when converting from time_t to tm then back to time_t
I have a time_t value of 1530173696 which represents Thursday, June 28, 2018 8:14:56 AM.
I want to round down the time to the nearest hour. Specifically, down to 1530172800, which represent Thursday, June 28, 2018 8:00:00 AM. So, my idea is to…

Abdulrahman Alhadhrami
- 655
- 4
- 17
0
votes
2 answers
swig/python detected a memory leak of type time_t
My code works, but the following warning appears:
swig/python detected a memory leak of type 'time_t *', no destructor found
How can I calm it down ?

Sophie Sperner
- 4,428
- 8
- 35
- 55
0
votes
1 answer
Inconsistent gmtime in C when recursively traversing directories
I have a C program where I use a recursive function that traverses a directory structure. It takes a time_t variable and creates a gmtime struct from it.
The recursive dir function is from How to recursively list directories in C on Linux?
void…

Kagemand Andersen
- 1,470
- 2
- 16
- 30
0
votes
1 answer
Making two time_t values the same day using gmtime and mktime, 'function may be unsafe' error
I am trying to use a time_t from the past, and a new time, and using gmtime, make them both a structure to which I can change the new time to the same day of the week, after this I wish to make the new changed time back into a time_t and return…

Daniel Peedah
- 171
- 9
0
votes
1 answer
creating formatted NSDate using NSDateFormatter or mktime
I'm just trying to create a NSDate object with string as:2011-02-10 4:30:45
Take a look at the code:
Approach OBJC:
-(NSDate *)get_date_df:(NSString *)dstr
{
NSLog(@"1> %@",dstr);
NSDateFormatter *df_in = [[[NSDateFormatter alloc]…

chunkyguy
- 3,509
- 1
- 29
- 34
0
votes
0 answers
How to set time_t function call to a passed-by time_t value?
I had a quick question about setting up values for function calls of type_t. In my project I have a parameterized constructor (within a function) of:
ShippingStatus s(location, status, timeUpdated)
and in this class there is a simple get function…

lawgik
- 87
- 3
- 10