unix-timestamp

TimeStamp Difference Between Java and SQLite

淺唱寂寞╮ 提交于 2019-12-01 23:43:39
Hello I have and SLQLite database in which I have table water_logs CREATE TABLE water_logs( _id INTEGER PRIMARY KEY AUTOINCREMENT, amount REAL NOT NULL, icon INTEGER NOT NULL, date INTEGER NOT NULL); I store date in milliseconds. Calendar cal = Calendar.getInstance(); cal.getTimeInMillis(); My problem is I want to get the day from the my date column using strftime function. The problem is tjat java calendar timestamp is different from SLQLite time stamp 1436859563832 --> result from cal.getTimeInMillis(); 1436607407--> SELECT strftime('%s','now') What I'm actually trying to do is to group

what is the windows equivalent of the command “date+%s”

不打扰是莪最后的温柔 提交于 2019-12-01 21:29:01
问题 I'm writing a batch script and I need the unix time. It's easy under linux, but I can't figure out how to do this in windows. 回答1: Here is a native batch solution that should work in any locale. It uses WMIC to get the current local time in a locale independent manner. Everything else is a "simple" matter of string parsing and basic math. :UnixTime [ReturnVar] [TimeStamp] :: :: Computes the Unix time from the current local time as reported by the :: operating system. The Unix time is the

Is there a direct way to convert Unix Time on Informix to YYYY-MM-DD HH:MM:SS?

让人想犯罪 __ 提交于 2019-12-01 21:01:13
I know something like this can be accomplished easily using PHP or Perl, but I want to know if there's a way to do it directly on Informix, something like the function FROM_UNIXTIME() on MySQL. I think you can do it using dbinfo with 'utc_to_datetime' as a parameter: http://publib.boulder.ibm.com/infocenter/idshelp/v115/index.jsp?topic=%2Fcom.ibm.sqls.doc%2Fids_sqs_1484.htm 来源: https://stackoverflow.com/questions/9213273/is-there-a-direct-way-to-convert-unix-time-on-informix-to-yyyy-mm-dd-hhmmss

Creating a boost::posix_time::ptime object from a 64 bit integer second count

爱⌒轻易说出口 提交于 2019-12-01 19:14:56
I have a 32 bit Linux system in which I have to record data that is timestamped with a UINT32 second offset from an epoch of 1901-01-01 00:00:00. Calculating the timestamp is ok for me as I can use the 64 bit ticks() counter and ticks_per_second() functions to generate the seconds since epoch as follows (I only require second level resolution) const ptime ptime_origin(time_from_string("1901-01-01 00:00:00")); time_duration my_utc = microsec_clock::universal_time() - ptime_origin; boost::int64_t tick_per_sec = my_utc.ticks_per_second(); boost::int64_t tick_count = my_utc.ticks(); boost::int64_t

Creating a boost::posix_time::ptime object from a 64 bit integer second count

烈酒焚心 提交于 2019-12-01 18:23:31
问题 I have a 32 bit Linux system in which I have to record data that is timestamped with a UINT32 second offset from an epoch of 1901-01-01 00:00:00. Calculating the timestamp is ok for me as I can use the 64 bit ticks() counter and ticks_per_second() functions to generate the seconds since epoch as follows (I only require second level resolution) const ptime ptime_origin(time_from_string("1901-01-01 00:00:00")); time_duration my_utc = microsec_clock::universal_time() - ptime_origin; boost::int64

Why does MySQL unix time stop short of the 32 bit unsigned integer limit?

人盡茶涼 提交于 2019-12-01 17:28:18
mysql> SELECT FROM_UNIXTIME(2145916799), FROM_UNIXTIME(2145916800), POW(2,32-1)-1, 2145916799 - POW(2,32-1)-1; +---------------------------+---------------------------+---------------+----------------------------+ | FROM_UNIXTIME(2145916799) | FROM_UNIXTIME(2145916800) | POW(2,32-1)-1 | 2145916799 - POW(2,32-1)-1 | +---------------------------+---------------------------+---------------+----------------------------+ | 2037-12-31 18:59:59 | NULL | 2147483647 | -1566850 | +---------------------------+---------------------------+---------------+----------------------------+ 1 row in set (0.00 sec

Calculate day number from an unix-timestamp in a math way?

邮差的信 提交于 2019-12-01 16:28:31
How can i calculate day number from a unix-timestamp, in a mathematical way and without using any functions and in simple math formula. 1313905026 --> 8 (Today 08/21/2011) JSideris There is no simple formula to do this. You would need to subtract the number of years (accounting for leap years) since the epoch, which would probably require a loop or a discrete calculation of some kind. Then use some type of loop to subtract out the number of seconds in each month for the current year. What you are left with is the number of seconds currently into the month. I would do something like this. x = .

unix timestamp to boost::posix_time::ptime

隐身守侯 提交于 2019-12-01 16:27:35
I need to convert double with number of seconds since the epoch to ptime . I'm prety sure there must be an easy way to do this, but I couldn't find anything. Thanks. Edit: The original timestamp is floating point. I can't change it and i don't want to lose the sub-second precision. Use the from_time_t() conversion function. A time_t is a UNIX timestamp, i.e. the number of seconds since the epoch. For a machine that has boost date/time compiled to the default level of microsecond resolution, try this: double ts = 1250524800.5; // Use floor() here if seconds are always positive. time_t

Calculate day number from an unix-timestamp in a math way?

孤街浪徒 提交于 2019-12-01 15:50:31
问题 How can i calculate day number from a unix-timestamp, in a mathematical way and without using any functions and in simple math formula. 1313905026 --> 8 (Today 08/21/2011) 回答1: There is no simple formula to do this. You would need to subtract the number of years (accounting for leap years) since the epoch, which would probably require a loop or a discrete calculation of some kind. Then use some type of loop to subtract out the number of seconds in each month for the current year. What you are

unix timestamp to boost::posix_time::ptime

心不动则不痛 提交于 2019-12-01 15:12:32
问题 I need to convert double with number of seconds since the epoch to ptime . I'm prety sure there must be an easy way to do this, but I couldn't find anything. Thanks. Edit: The original timestamp is floating point. I can't change it and i don't want to lose the sub-second precision. 回答1: Use the from_time_t() conversion function. A time_t is a UNIX timestamp, i.e. the number of seconds since the epoch. 回答2: For a machine that has boost date/time compiled to the default level of microsecond