time-t

64-bit time_t in Linux Kernel

£可爱£侵袭症+ 提交于 2021-01-28 06:12:05
问题 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 on a particular option during make menuconfig? 回答1: Currently time_t is just long in kernel: see __kernel_time_t type definition. So if long type on your CPU is 32-bit long, time_t also is 32-bit long. Basically, if you have 32-bit CPU -- long type on your system is also 32-bit long. If you have 64-bit

javascript date time_ t conversion

*爱你&永不变心* 提交于 2020-01-25 07:40:06
问题 I'm having a problem with the date format in javascript. I'm getting a date in seconds (in time_t format) from a database (ex. 1364565600) Now I want to convert this date to day, month, day (ex. Tuesday, March, 18th). I hope this is possible. timestart: function (time_start) { /////////////////////////////// //////code for conversion////// return time_start; } Thanks in advance! 回答1: Multiply the seconds you're getting by 1000 and use a new Date() object, which takes milliseconds as a

Standard conformant way of converting std::time_t to System::DateTime?

痞子三分冷 提交于 2019-12-17 19:29:04
问题 I have already found several answers related to converting a std::time_t value to System::DateTime and back. However, almost all answers seem to neglect that the type of std::time_t is actually undefined in the standard. Most solutions just cast std::time_t to whatever needed or apply arithmetic operations to a std::time_t object which is possible since it's an arithmetic type, but there is no specification about the result of such an operation. I know that most compilers define time_t as an

What primitive data type is time_t? [duplicate]

风格不统一 提交于 2019-12-17 06:49:58
问题 This question already has answers here : What is time_t ultimately a typedef to? (10 answers) Closed 2 years ago . 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 there for displaying time_t but I need to know the data type that corresponds with it. 回答1: Unfortunately, it's not completely portable. It's usually integral, but it can be any "integer or

Get the current time in C

耗尽温柔 提交于 2019-12-17 05:40:53
问题 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", mytime) ) { printf("time1 = \"%s\"\n", buffer); } The problem is that this code is giving some random time. Also, the random time is different everytime. I want the current time of my system. 回答1: Copy-pasted from here: /* localtime example */ #include <stdio.h> #include <time.h> int main () { time_t rawtime;

Comparing time_t values using comparison operators

余生长醉 提交于 2019-12-13 11:35:12
问题 I have 2 time_t values and I want to find out which one is greater. time_t is internally __int64 on my platform. Can I use < , > and == operators to compare the values? I don't want to know the difference between the two time values. The code will just run on Windows, so I don't care about portability. Is it correct to compare the values in this way? 回答1: According to section 7.27.1(3) of the C standard (which the C++ standard refers to in this case) time_t is a real type , which is defined

How do I get time_t in GMT on Windows in C

邮差的信 提交于 2019-12-10 07:54:55
问题 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 want to get time_t in GMT. I've been looking through the time.h functions, but it is unclear to me how I can be sure that I will get the time correctly. This is what I've come up with so far: time_t t = time(); struct tm *gtm = gmtime(&t); time_t gt = mktime(gtm); Now, this seems to get the correct