unix-timestamp

Convert unix timestamp to javascript date Object [duplicate]

妖精的绣舞 提交于 2019-12-04 22:50:44
This question already has answers here : How do I format a Microsoft JSON date? (40 answers) Closed 5 years ago . Am working with json api that represents dates like this "date" : "/Date(1356081900000)/" I want to turn this into regular javascript Date. The only way I can think of solving this problem is to do a replace on everything leaving the timestamp which I can then "convert". This works but it just looks wrong. My question. Can I do this in better way? UPDATE unix_timestamp = jsonDate.replace('/Date(', '').replace(')/', ''); newDate = new Date(+unix_timestamp + 1000*3600); antila

Problems with finding the days between two unix timestamps

时光总嘲笑我的痴心妄想 提交于 2019-12-04 20:24:36
I know there a lot of questions and answers of this already, but unfortunately I think my situation may be unique? For some reason, the time-change seems to be making the day calculate as one day less than it should be calculating. Here is my PHP that I was using and it was working great, until it started to overlap a start and end date that was BEFORE daylight savings, and AFTER daylight savings, respectively (FYI, this is a recent issue, since daylight savings time starts this weekend!): //$lastDate and $firstDate are 2 unix timestamps with valid month, day, and year values. //The times are

Convert Datetime to Unix timestamp

蹲街弑〆低调 提交于 2019-12-04 18:58:05
问题 In Microsoft SQL Server 2012 or above, is it possible to convert a datetime value to Unix time stamp in a single select statement? If so, how can it be done? 回答1: As Peter Halasz mentions in T-SQL DateTime to Unix Timestamp: Converting a datetime to unix timestamp is easy, but involves error prone typing the following: @timestamp=DATEDIFF(second,{d '1970-01-01'},@datetime) Where @datetime is the datetime value you want to convert. The {d ‘yyyy-mm-dd’} notation is an ODBC escape sequence. The

Oracle SQL Date to Long and vice versa

你离开我真会死。 提交于 2019-12-04 17:01:08
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. You are losing too much precision in your conversion to be able to go back the other way. You can get closer

spark unix_timestamp data type mismatch

99封情书 提交于 2019-12-04 15:49:48
Could someone help guide me in what data type or format I need to submit from_unixtime for the spark from_unixtime() function to work? When I try the following it works, but responds not with current_timestamp. from_unixtime(current_timestamp()) The response is below: fromunixtime(currenttimestamp(),yyyy-MM-dd HH:mm:ss) When I try to input from_unixtime(1392394861,"yyyy-MM-dd HH:mm:ss.SSSS") The above simply fails with a type mismatch: error: type mismatch; found : Int(1392394861) required: org.apache.spark.sql.Column from_unixtime(1392394861,"yyyy-MM-dd HH:mm:ss.SSSS") What am I missing? I've

How to write an SQL query that counts the number of rows per month and year?

蓝咒 提交于 2019-12-04 11:16:39
Had anyone any idea how to query a vbulletin database to generate a report on the number of registrations per month/year to achive results like.. MM/YYYY Count 01/2001 : 10 02/2001 : 12 ... ... Thanks to those answers below.. My final version that works is as follows: SELECT COUNT(*) as 'Registrations', YEAR(FROM_UNIXTIME(joindate)) as 'Year', MONTH(FROM_UNIXTIME(joindate)) as 'Month' FROM vbfuser GROUP BY Year,Month I am not familiar with vBulletin's database structure, but you should do something like this , assuming your user table has a date/datetime/timestamp created_date or reg_timestamp

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

牧云@^-^@ 提交于 2019-12-04 10:57:42
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 Mac OSX is that makes any difference. $ perl -lne 'print scalar gmtime $_' test.txt Wed Jul 19 18:56:41

Java Converting 19-digit Unix Timestamp to a Readable Date

爷,独闯天下 提交于 2019-12-04 07:04:51
问题 I am trying to convert 19 digit Unix timestamp such as 1558439504711000000 (one and a half quintillion) into a readable date/time format. My timestamp ends with 6 zeros which suggests the time is in nano seconds. I have come across some examples where people have used time zones which I don't need. Another example uses ofEpochSecond like so: Instant instant = Instant.ofEpochSecond(seconds, nanos); But I am not sure whether I need to use ofEpochSecond. The code below gives my most recent

How get accurate UTC timestamp in android

社会主义新天地 提交于 2019-12-04 05:50:23
问题 I do not know which one is right for get UTC time My code is System.currentTimeMillis() for java android Is the result correct for international? Maybe user can change device time and result be different? (Does it affect on UTC?) 回答1: On Linux platform, the system clock should be set to UTC. Whether it actually is, and whether it is accurate, is ultimately up to the user. Calling System.currentTimeMillis() will give the time in UTC since 1970-01-01T00:00:00Z . Is the result correct for

Converting timestamp in microseconds to data and time in r

冷暖自知 提交于 2019-12-04 05:33:51
问题 I'm trying to convert a timestamp in microseconds to the following format in R: YYYY-MM-DD HH:MM:SS I've tried different approaches, but couldn't succeed. Following my code: options(digits=16) value = 1521222492687300 as.POSIXct(value, tz = "UTC", origin="1970-01-01 00:00:00") And I get this as return: [1] "48207591-10-13 12:15:00 UTC" Even divided by 1000, as some posts suggested, I'm still getting a non sense result: as.POSIXct(value/1000, tz = "UTC", origin="1970-01-01 00:00:00") [1]