Skip to main content

All Questions

Tagged with
0 votes
3 answers
1k views

How to get milliseconds passed since unix epoch in C without multiplying seconds by 1000?

The only thing I know is time(NULL), but it return seconds since 1970. It's fine to me to use WinApi functions if C doesn't have needed function. I even found GetLocalTime WinApi function, but it ...
Kosmo零's user avatar
  • 4,081
0 votes
1 answer
534 views

How to measure CPU time of a process in C?

I would like to measure the CPU and User time passed between starting a process and sending SIGINT signal using C times function. However, on print I just get 0. Can't see the problem.. #include <...
TMOTTM's user avatar
  • 3,353
1 vote
2 answers
295 views

Unix Time stamp creation in C from custom data fields

I wish to create a Unix time stamp. I have a micro-controller with a ble connection that I send the present time to via a GATT connection. I receive the data several integers. These are Year, Month, ...
Thomas Morris's user avatar
2 votes
1 answer
585 views

MinGW localtime_r works in one time zone, fails in another

I have the following file test.c: #define _POSIX_THREAD_SAFE_FUNCTIONS #include <time.h> #include <stdio.h> #include <string.h> #include <stdint.h> #include <inttypes....
Simon Kissane's user avatar
0 votes
0 answers
86 views

Unix time -> string using C on mobile (Android/iOS)

Given a Unix time, as number of seconds since Jan 1st, 1970, how can I convert that to a human-readable string (say, ISO-8601) using C on Android and iOS? The standard library's time.h implementation ...
me--'s user avatar
  • 2,088
0 votes
1 answer
395 views

Is it safe to use (UTC Unix timestamp % 60) as the UTC seconds field?

I have an embedded device that's doing a crude time sync with a Linux-based wireless gateway's Unix time (time_t), which is set to UTC. I need to align some of my actions with the wall-clock time -- ...
Adam Haun's user avatar
  • 408
0 votes
1 answer
511 views

create unix timestamp before 1970 on windows using mktime in c

Using c I'd like to create a unix timestamp for dates before 1970 with visual studio (or preferably both VS and GCC). The timestamp should be created from date parts. From what I can tell visual ...
Jimbo's user avatar
  • 3,194
1 vote
3 answers
2k views

Converting unix time into readable time

I've got the unix time since January 1st 1970 (E.G 1531074816) from my GPS module, how do I convert this into a readable format? I only need to get the current hour, minutes and seconds. I'm not ...
Joe's user avatar
  • 47
15 votes
6 answers
3k views

Will `gmtime()` report seconds as 60 when in a leap second?

I have a server running in TZ=UTC and I have code like this: time_t t = time(NULL); struct tm tm; gmtime_r(&t, &tm); The question is will tm.tm_sec == 60 when the server is within a leap ...
Yuki's user avatar
  • 4,055
-2 votes
1 answer
2k views

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(...
Syler's user avatar
  • 1,161
2 votes
2 answers
495 views

get process start time in kernel module solaris

I am trying to get process start time in kernel module. I get the proc struct pointer, and from the proc I take field p_mstart () typedef struct proc { ..... /* * Microstate accounting, resource ...
ilansch's user avatar
  • 4,854
2 votes
1 answer
1k views

Date formatting in pure C using time zones

I want to implement Unix milliseconds converter to human readable date format. using this post https://stackoverflow.com/a/1657307/1979882 I found I can receive such string but I can't setup a time ...
Vyacheslav's user avatar
0 votes
2 answers
944 views

strptime does not works with timezone format specifier

I am new to c and trying out on strptime function, which converts string time to structure tm. After converting i am not getting right time. everything is fine but year is displaying wrong(default ...
Ravi Bhushan's user avatar
2 votes
2 answers
1k views

c/c++ - convert between Unix time and the "Gregorian time"

I now have timestamps which are in microseconds since midnight, January 1st, 0 AD nominal Gregorian, after searching I noticed that some people call this "native Symbian time"? Whatever it is, I ...
xl46's user avatar
  • 23
4 votes
2 answers
2k views

time function in C always displays "Wed Dec 31 23:59:59 1969"

I require the current date and time to be logged for my application. I have written the code in C. I have attached the code #include <stdio.h> #include <time.h> int main() { time_t t; ...
Injitea's user avatar
  • 69

15 30 50 per page