timestamp

Socket reading and timestamps

放肆的年华 提交于 2020-01-13 10:46:29
问题 When reading from a (non-stream) socket in Linux, I can get the (hardware-generated) timestamp of the last received message via a ioctl(sock, SIOCGSTAMP, &tv) . However, this poses two problems: It is another syscall (I'm receiving about 24000 messages per second, so each syscall is notifiable) If using this approach, I can only read() one message at a time, followed by the ioctl() to get the timestamp. (If I'm reading more than one message in a read() -call, the following ioctl only yields

Is there a way to retroactively create time/node based UUID in PHP?

回眸只為那壹抹淺笑 提交于 2020-01-13 10:16:19
问题 Most time-based (type 1) UUIDs are created using the current time. I'm migrating a MySQL database to cassandra and would like to create timebased UUIDs for archived items. Can someone provide an example of how type-1 UUIDs are created using past time periods? 回答1: All uuids version 1 are a combination of node identifier (MAC address), timestamp and a random seed. Yes its possible. The process is reversible. From RFC4122 about the timestamp part of UUID version 1 (section 4.1.4): "For UUID

Find intersections between rows and timestamps in a mysql db

孤人 提交于 2020-01-13 09:36:09
问题 I have a table, where events of certain objects are listed. There are two events: "movement" and "load". They can start and end, and these events are listed with timestamps when they happened. Now i want to calculate the following three numbers: sum of time, when movement took place (value in the fiddle: 700) sum of time, when load took place (value in the fiddle: 630) sum of time, when movement and load took place (value in the fiddle: 611) I have created a sqlfiddle for the problem here:

Get Date from timestamp in Groovy

泄露秘密 提交于 2020-01-13 08:43:17
问题 As trivial as it may seem, I cannot find a way to transform a Unix timestamp into a Date object in Groovy. Let me try with 1280512800 , which should become Fri, 30 Jul 2010 18:00:00 GMT My first attempt was new Date(1280512800) // wrong, becomes Thu Jan 15 20:41:52 CET 1970 Then I read that Java timestamps use milliseconds, hence I should use new Date((long)1280512800 * 1000) // the cast to long is irrelevant in Groovy, in any case I get // Thu Jan 08 03:09:05 CET 1970 What is the right way

Get Date from timestamp in Groovy

£可爱£侵袭症+ 提交于 2020-01-13 08:42:06
问题 As trivial as it may seem, I cannot find a way to transform a Unix timestamp into a Date object in Groovy. Let me try with 1280512800 , which should become Fri, 30 Jul 2010 18:00:00 GMT My first attempt was new Date(1280512800) // wrong, becomes Thu Jan 15 20:41:52 CET 1970 Then I read that Java timestamps use milliseconds, hence I should use new Date((long)1280512800 * 1000) // the cast to long is irrelevant in Groovy, in any case I get // Thu Jan 08 03:09:05 CET 1970 What is the right way

Converting date/time string to unix timestamp in MySQL

荒凉一梦 提交于 2020-01-13 07:28:07
问题 We have a database with all the dates and times stored in one column called timestamp. The format of the date/time in the column "timestamp" is as: 03 Aug 08:10am. I would like to convert this (03 Aug 08:10am) to UNIX TIMESTAMP in MySQL and not PHP because we already have over 500 rows with this format: 03 Aug 08:10am. I tried create a new INT column called new_timestamp and ran this query: UPDATE table_name SET new_timestamp = UNIX_TIMESTAMP(timestamp); However, it shows that 0 rows were

PHP timestamp to HTML 5 input type=datetime element

旧街凉风 提交于 2020-01-12 23:21:12
问题 I have a unix timestamp (int) in PHP. I want to display this value in a nice manner in the HTML5 datetime input element. I would like to be able to have users see this value in a nice presentable manner, as well as edit it. Is there any nice way of doing this, or am I fooling myself and I am going to have to fuss around with lots of string manipulation? 回答1: HTML5 Input time is something like this : 1985-04-12T23:20:50.52 You can do that in PHP like this : echo date("Y-m-d\TH:i:s"); Output

PHP timestamp to HTML 5 input type=datetime element

本秂侑毒 提交于 2020-01-12 23:17:07
问题 I have a unix timestamp (int) in PHP. I want to display this value in a nice manner in the HTML5 datetime input element. I would like to be able to have users see this value in a nice presentable manner, as well as edit it. Is there any nice way of doing this, or am I fooling myself and I am going to have to fuss around with lots of string manipulation? 回答1: HTML5 Input time is something like this : 1985-04-12T23:20:50.52 You can do that in PHP like this : echo date("Y-m-d\TH:i:s"); Output

How to maintain precision using DateTime.Now.Ticks in C#

妖精的绣舞 提交于 2020-01-12 18:50:15
问题 I know that when I use DateTime.Now.Ticks in C# it returns a long value but I need to store it in an int variable and I am confused as to whether or not I can maintain that precision. As of right now I just have a cast int timeStampValue = (int)DateTime.Now.Ticks; This is a project constraint so I understand there is tons of precision lost. I guess I just couldn't think of another way to do a timestamp thing stored in an int that I could then compare to other timestamps. Any suggestions or

How to maintain precision using DateTime.Now.Ticks in C#

戏子无情 提交于 2020-01-12 18:50:11
问题 I know that when I use DateTime.Now.Ticks in C# it returns a long value but I need to store it in an int variable and I am confused as to whether or not I can maintain that precision. As of right now I just have a cast int timeStampValue = (int)DateTime.Now.Ticks; This is a project constraint so I understand there is tons of precision lost. I guess I just couldn't think of another way to do a timestamp thing stored in an int that I could then compare to other timestamps. Any suggestions or