Questions tagged [time-t]

`time_t` is a Standard-C data type to hold the seconds since UNIX epoch, that since the 1.1.1970.

171 questions
-1
votes
1 answer

Reading and displaying time stamp from a binary file

I am currently working on a college c project in which I have wrote readings saved in a struct to a binary file. In this struct I am also saving the time and date of which the items were entered. i am then opening the file in a seperate program and…
-1
votes
2 answers

Char to time_t conversion always returns Wed Dec 31 23:59:59 1969

I am working on some code for my ESP8266 in Arduino. I want to send a timestamp to another ESP via UDP. In the setup(){ I initialize the time using configTime(3 * 3600, 0, "pool.ntp.org", "time.nist.gov"); and in the loop(){ time_t timestamp =…
binarykitten
  • 61
  • 1
  • 9
-1
votes
2 answers

Set string as current date

I need to write files with the current date included in the name. Currently this is what I have tried: time_t t = time(0); struct tm * now = localtime(&t); string date=now->tm_mday+'/'+(now->tm_mon+1)+'/'+(now->tm_year+1900); Preferably…
Cameron L
  • 86
  • 12
-2
votes
1 answer

Standard C - How to use a unix epoch timestamp other than Jan 1, 1970?

Timestamp is defined as the number of seconds elapsed since midnight of January 1, 2000, UTC. Using standard C only, how to get unix timestamp with epoch of Jan 1, 2000 UTC and not Jan 1, 1970? time(NULL) returns seconds since January 1,…
Syler
  • 1,151
  • 1
  • 13
  • 30
-2
votes
3 answers

struct tm inside another struct - c

I'm trying to calculate the date difference between two dates, using mktime and difftime. One of the dates is a struct tm inside another struct and the other date is a struct tm inside main. mktime works fine one the date inside main, but keeps…
-3
votes
1 answer

How to properly send time_t pointer to function? Encountering valgrind error when trying to do so

I am trying to send a time_t to a function by using a time_t pointer variable. I don't get any compiler warnings when compiling my code, but a valgrind error when I run the code with valgrind. My code: printTime(time_t *time){
J. Doe
  • 7
  • 1
1 2 3
11
12