unix-timestamp

I need the SQLite equivalent of MySQL for working with unix timestamps

喜欢而已 提交于 2019-12-07 12:24:14
问题 I'm using unix timestamps with SQLite and storing them as an integer. My problem is that I am trying to select records for today based on their unix timestamps and I have no clue what functions to use. Here is what I would use in MySQL: where date_format(from_unixtime(COLUMN_DATE), '%Y-%m-%d')= date_format(now(), '%Y-%m-%d') However when I try to use these functions I'm getting errors in the log telling me they don't exist for SQLite. How do I write this for SQLite? 回答1: SQLite date and time

Do you know of a C macro to compute Unix time and date?

若如初见. 提交于 2019-12-07 11:54:06
问题 I'm wondering if someone knows/has a C macro to compute a static Unix time from a hard coded date and time as in: time_t t = UNIX_TIMESTAMP(2012, 5, 10, 9, 26, 13); I'm looking into that because I want to have a numeric static timestamp. This will be done hundred of times throughout the software, each time with a different date, and I want to make sure it is fast because it will run hundreds of times every second. Converting dates that many times would definitively slow down things (i.e.

Leap second handling in database

半城伤御伤魂 提交于 2019-12-07 07:01:03
问题 As: The Unix time number is zero at the Unix epoch, and increases by exactly 86400 per day since the epoch. So it cannot represent leap seconds. The OS will slow down the clock to accomodate for this. So, if I am storing Unix epoch (e.g. ts) in DB (milli-second accuracy), how to handle the following case? How to make sure the the ts is always increasing and no backward? How to select exactly the 100s interval from db which take account into the leap second? e.g. SELECT * FROM events WHERE ts

When was Unix epoch time revised from 1971 to current 1970 value?

假装没事ソ 提交于 2019-12-07 06:04:10
问题 According to the first edition Unix Programmer's Manual, Unix time is defined as "the time since 00:00:00, January 1, 1971, measured in sixtieths of a second" When did this change to its current value of midnight (UTC), January 1, 1970? 回答1: In First Edition Unix (November 1971), the manual page for the time system call stated that it returned "the time since 00:00:00, Jan. 1, 1971, measured in sixtieths of a second". This was a 32-bit value, so even treated as unsigned it could only track

Gson dateformat to parse/output unix-timestamps

妖精的绣舞 提交于 2019-12-07 01:01:07
问题 I am using Gson to serialize/deserialize my pojos and currently looking for a clean way to tell Gson to parse/output date attributes as unix-timestamps. Here's my attempt: Gson gson = new GsonBuilder().setDateFormat("U").create(); Comming from PHP where "U" is the dateformat used to parse/output date as unix-timestamps, when running my attempt code, I am getting this RuntimeException: Unknown pattern character 'U' I am assuming that Gson uses SimpleDateformat under the hood which doesn't

How can I display a formatted date from a Unix timestamp in twig?

…衆ロ難τιáo~ 提交于 2019-12-06 17:11:28
问题 I would like to display a formatted date in twig by applying a filter to a Unix timestamp. Is such a feature available in twig? 回答1: There is a filter called date. In the following example mydate equals 1286199900 : {{ mydate|date }} <!-- October 4, 2010 13:45 --> {{ mydate|date('d/m/Y') }} <!-- 04/10/2010 --> 回答2: If you just divide it by 1000 there might be an error like Failed to parse time string (1384361503.5) at position 7 I would add round function to it {% set timestamp = (rating

Oracle SQL Date to Long and vice versa

一曲冷凌霜 提交于 2019-12-06 11:28:17
问题 I have the following SQL Query which converts the long number to a date , i cannot convert the date back to the long number . kindly let me know your suggestion. SELECT to_date((( 1432550197431912935 - POWER(2,60)) /POWER(2,44)) + to_date('01-JAN-1970','DD-MON-YYYY')) from dual Output 7/9/2013 select TO_CHAR(((TO_DATE ('09-JUL-2013','DD-MON-YYYY') -to_date('01-JAN-1970','DD-MON-YYYY')) * POWER(2,44) ) + POWER(2,60)) from dual Output 1432549301782839296 The long values are not the same. 回答1:

Wrong value returned after formatting timestamp

允我心安 提交于 2019-12-06 09:52:25
I am trying to format a timestamp but the wrong value is returned. let timestampDouble: Double = 1455970380471 let timestamp = NSDate(timeIntervalSince1970: timestampDouble) let formattedTimestamp = NSDateFormatter.localizedStringFromDate(timestamp, dateStyle: .MediumStyle, timeStyle: .ShortStyle) formattedTimestamp returns Jun 22, 48115, 8:49 AM instead of the correct timestamp of Feb 20, 2016, 11:13 PM (from epochconverter.com ). You've got the wrong value. I reversed the process, starting with the date string you want, and ran it through this code: let dateFormatter = NSDateFormatter()

Unix Timestamp bigint(20)

陌路散爱 提交于 2019-12-06 07:34:07
I am doing research in a MySQL database, and I suppose some timestamps are in Unix format. Those timestamps are in a bigint(20) field. I'm going crazy about them. How can I convert these to a regular timestamp? Example: 634583466272408810 634587264000000000 try select from_unixtime(634583466272408810/1000000000) See FROM_UNIXTIME 来源: https://stackoverflow.com/questions/12090772/unix-timestamp-bigint20

How can I convert a file full of unix time strings to human readable dates?

[亡魂溺海] 提交于 2019-12-06 06:35:00
问题 I am processing a file full of unix time strings. I want to convert them all to human readable. The file looks like so: 1153335401 1153448586 1153476729 1153494310 1153603662 1153640211 Here is the script: #! /bin/bash FILE="test.txt" cat $FILE | while read line; do perl -e 'print scalar(gmtime($line)), "\n"' done This is not working. The output I get is Thu Jan 1 00:00:00 1970 for every line. I think the line breaks are being picked up and that is why it is not working. Any ideas? I'm using