milliseconds

ActiveRecord: milliseconds aren't taken into account when using a where clause

不想你离开。 提交于 2019-12-01 05:43:53
I'm working on a project with a rails api and an iOS client, using the updated_at field as the reference to detect modifications on the server that happened after the last pull from the client. The updated_at datetime has a precision in milliseconds, meaning that Model.updated_at.to_f returns something like "1368977381.063427". This is sent to the client formatted as "2013-05-19T15:29:41.063427000Z". The trouble is, when I get that datetime back from the client, parse it and query with it, the milliseconds are lost. last_update = DateTime.strptime("2013-05-19T15:29:41.063427000Z", "%Y-%m-%dT%H

ActiveRecord: milliseconds aren't taken into account when using a where clause

℡╲_俬逩灬. 提交于 2019-12-01 02:12:20
问题 I'm working on a project with a rails api and an iOS client, using the updated_at field as the reference to detect modifications on the server that happened after the last pull from the client. The updated_at datetime has a precision in milliseconds, meaning that Model.updated_at.to_f returns something like "1368977381.063427". This is sent to the client formatted as "2013-05-19T15:29:41.063427000Z". The trouble is, when I get that datetime back from the client, parse it and query with it,

How to retrieve microseconds or milliseconds from MySQL current time?

你说的曾经没有我的故事 提交于 2019-11-30 14:53:31
问题 I am trying to create my first stored function on MySQL. In this function I want to return the timestamp of the current date and time with 3 microsecond digits like this: YYYYMMDDHHMMSSZZZ I use this number in my database to create unique keys for my records offline so they don't crash when my systems merge databases from different offline servers. So my first try for that was SELECT CAST(MICROSECOND(NOW()) AS CHAR(3)); But it returns 0. If I try SELECT CAST(MICROSECOND('2009-12-31 23:59:59

SQL Server 2008 and milliseconds

♀尐吖头ヾ 提交于 2019-11-30 08:58:07
问题 In SQL Server 2008, why do the following queries return the same value? -- These all return 2011-01-01 23:59:59.997 SELECT CAST('2011-01-01 23:59:59.997' as datetime) SELECT CAST('2011-01-01 23:59:59.998' as datetime) And why does the following query round to the next day? -- Returns 2011-01-02 00:00:00.000 SELECT CAST('2011-01-01 23:59:59.999' as datetime) 回答1: The accuracy of DateTime within SQL Server has always been to 1/300s of a second (3.33ms), so any value that does not divide

milliseconds to days

老子叫甜甜 提交于 2019-11-30 06:20:33
问题 i did some research, but still can't find how to get the days... Here is what I got: int seconds = (int) (milliseconds / 1000) % 60 ; int minutes = (int) ((milliseconds / (1000*60)) % 60); int hours = (int) ((milliseconds / (1000*60*60)) % 24); int days = ????? ; Please help, I suck at math, thank's. 回答1: If you don't have another time interval bigger than days: int days = (int) (milliseconds / (1000*60*60*24)); If you have weeks too: int days = (int) ((milliseconds / (1000*60*60*24)) % 7);

new Date(milliseconds) returns Invalid date

随声附和 提交于 2019-11-30 03:07:10
I am trying to convert milliseconds to a date using the javascript using: new Date(Milliseconds); constructor, but when I give it a milliseconds value of say 1372439683000 it returns invalid date. If I go to a site that converts milliseconds to date it returns the correct date. Any ideas why? You're not using a number, you're using a string that looks like a number. According to MDN, when you pass a string into Date , it expects a format recognized by the parse method (IETF-compliant RFC 2822 timestamps). An example of such a string is " December 17, 1995 03:24:00 ", but you're passing in a

How to convert milliseconds to seconds with precision

余生颓废 提交于 2019-11-29 10:52:04
问题 I want to convert milliseconds to seconds (for example 1500ms to 1.5s, or 500ms to 0.5s) with as much precision as possible. Double.parseDouble(500 / 1000 + "." + 500 % 1000); isn't the best way to do it: I'm looking for a way to get the remainder from a division operation so I could simply add the remainder on. 回答1: Surely you just need: double seconds = milliseconds / 1000.0; There's no need to manually do the two parts separately - you just need floating point arithmetic, which the use of

file.lastModified() is never what was set with file.setLastModified()

╄→гoц情女王★ 提交于 2019-11-29 09:32:23
I do have a problem with millis set and read on Android 2.3.4 on a Nexus One. This is the code: File fileFolder = new File(Environment.getExternalStorageDirectory(), appName + "/" + URLDecoder.decode(folder.getUrl())); if (fileFolder != null && !fileFolder.exists()) { fileFolder.setLastModified(1310198774); fileFolder.mkdirs(); fileFolder.setLastModified(1310198774); } if (fileFolder != null && fileFolder.exists()) { long l = fileFolder.lastModified(); } In this small test I write 1310198774 but the result that is returned from lastModified() is 1310199771000. Even if I cut the trailing "000"

SQL Server 2008 and milliseconds

走远了吗. 提交于 2019-11-29 09:21:37
In SQL Server 2008, why do the following queries return the same value? -- These all return 2011-01-01 23:59:59.997 SELECT CAST('2011-01-01 23:59:59.997' as datetime) SELECT CAST('2011-01-01 23:59:59.998' as datetime) And why does the following query round to the next day? -- Returns 2011-01-02 00:00:00.000 SELECT CAST('2011-01-01 23:59:59.999' as datetime) Andrew The accuracy of DateTime within SQL Server has always been to 1/300s of a second (3.33ms), so any value that does not divide precisely gets rounded. 997 stays as it is 998 will round to 997 999 will round up to 000 To get additional

R issue with rounding milliseconds

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 07:13:21
Given the following issue with rounding milliseconds under R. How do I get around it so that the times are correct? > options(digits.secs=3) > as.POSIXlt("13:29:56.061", format='%H:%M:%OS', tz='UTC') [1] "2012-06-07 13:29:56.060 UTC" > as.POSIXlt("13:29:56.062", format='%H:%M:%OS', tz='UTC') [1] "2012-06-07 13:29:56.061 UTC" > as.POSIXlt("13:29:56.063", format='%H:%M:%OS', tz='UTC') [1] "2012-06-07 13:29:56.063 UTC" I noticed that this URL provides background information but doesn't solve my issue: Milliseconds puzzle when calling strptime in R . Also this URL touches on the issue but doesn't