`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
0 answers
strftime issue with different formats
string Account::dateCreated(){
time_t rawtime;
struct tm * timeinfo;
char buffer [80];
time (&rawtime);
timeinfo = localtime (&rawtime);
strftime (buffer,80,"%a %b %d %T %Z %Y",timeinfo);
return buffer;
}
For…

Neil Shah
- 33
- 4
0
votes
1 answer
64-bit operations sometime fail
It's the first time I use 64-bit time_t structure to do operations with time. The compiler is the TI's C Compiler for CC3220SF.
Here my function that should return the seconds to the next event:
#define ACQ_INTERVAL 1 // in minutes
time_t…

Mark
- 4,338
- 7
- 58
- 120
0
votes
1 answer
Using struct utimbuf to change file access time
I use a utimbuf to change actime to the present time
and modtime tries to change to time of one month later
struct utimbuf timebuf;
timebuf.actime = time((time_t *)0);
timebuf.modtime = time((time_t *)0) + 2678400;
When using time(), Is there any…

Joy.k
- 9
- 3
0
votes
1 answer
How to store a time_t field to MySQL datetime?
I have extracted the modification time of a file using the struct stat structure:
long modtime = image_stats.st_mtime;
This returns 1508240128.
Now, I wish to store this value into a MySQL table which has datatype as datetime.
If I store it…

RajSanpui
- 11,556
- 32
- 79
- 146
0
votes
2 answers
How to store the random seed generated from time(NULL) in a text file?
I am creating random numbers for my code and I am using the seeding method for the purpose of debugging. What I want to do is to store the return value of time(NULL) function which will be used by the srand() function. The value is to be stored in a…

KulaDamian
- 154
- 2
- 14
0
votes
0 answers
mktime subtracts an hour from my dates
I have made two simple functions that can serialize and deserialize a time_t to a iso 8601 string format:
#include
#include
std::string time_t_to_iso_format(std::time_t time)
{
char buf[sizeof…
user2882307
0
votes
1 answer
How to get the min/max value of time_t (if type is unknown)
UBSAN complains about undefined behavior for when I run the antiword utility:
runtime error: left shift of 1 by 63 places cannot be represented in type 'time_t' (aka 'long')
The error is triggered by the macros for TIME_T_MIN and TIME_T_MAX…

Jeroen Ooms
- 31,998
- 35
- 134
- 207
0
votes
1 answer
localtime_s fails where gmtime_s succeeds with dates before 1-1-1970
I'm trying to get the current year stored in a date from before 1970 using an std::chrono::time_point, however I've run into an issue regarding the reading from its contents into a std::tm struct.
I convert the time_point…

Qub1
- 1,154
- 2
- 14
- 31
0
votes
4 answers
C - time_t string representation
I am new to C programming and I would like some help with a simple task.
So I have this function:
char *time2str(time_t time) {
static_char *str_fmt = "%02d/%02d/%4d %02d:%02d";
char *time_s = "";
return time_s;
}
What I would like…

ZedZerg
- 53
- 7
0
votes
1 answer
How do I convert a time to tm struct instead of CTime class
I currently have code that creates a CTime object from a defined value.
#define TIME_VALUE 0x301DDF00 // Aug 1, 1995 @ 04:00:00
CTime t = CTime( TIME_VALUE );
This creates the desired date of Aug 1, 1995 04:00:00
I can no longer use CTime so I am…
0
votes
1 answer
gmtime won't work for a object read with overloaded operator
So I've made a class for a location,in which I store it's coordonates and it's time,in utc. I overloaded the >> operator like this
friend ifstream& operator >>(ifstream& in, loc_list& l)
{
char bf[40];
in >> bf;
l.setID(bf);
long…
0
votes
1 answer
tmElements_t.Year trunks bits from 2015 to 223
I want to create a unixtime, to make some calcs.
But when I save the year() (2015) in tmElements_t.Year, it trunks the bits and returns 223.
time_t ahora = now();
tini.Year=year(ahora); //2015 to…

perez_chuck
- 17
- 4
0
votes
3 answers
int to time_t* type for printing
Reading info from files and printing them out. I save the modification time from stat as an int called mod_time into a struct to recall later. However, when I want to use the ctime()function, I run into a problem because that takes a time_t* type…

jiccan
- 89
- 12
0
votes
3 answers
write a std::string to comparable *time* parser which may fail
I know that size_t is unsigned and hence negative values are not allowed, time_t is to the best of my knowledge signed, so I am allowed to assign -1 to a size_t. However, for time_t I'm not entirely sure. If I follow the definition through the…

Herbert
- 5,279
- 5
- 44
- 69
0
votes
0 answers
strptime string time parsing error into time_t
I'm trying to fetch time value in %Y-%m-%d %H:%M:%S format from mysql and store it in time_t. I'm using two functions for that.
#include
#include
#include
#include
/* convert string time stamp format to…

sandun dhammika
- 881
- 3
- 12
- 31