unix-timestamp

How to convert date string to timestamp in Kotlin?

蓝咒 提交于 2021-02-18 09:45:16
问题 I want to convert a date string to unix timestamp from a date string e.g. 14-02-2018 Can someone help? 回答1: Since JDK 8 you can do: val l = LocalDate.parse("14-02-2018", DateTimeFormatter.ofPattern("dd-MM-yyyy")) val unix = l.atStartOfDay(ZoneId.systemDefault()).toInstant().epochSecond Note that the example uses your system's default timezone. 回答2: use this to convert the date string to UNIX timestamp val date = SimpleDateFormat("dd-MM-yyyy").parse("14-02-2018") println(date.time) 来源: https:/

How to convert date string to timestamp in Kotlin?

二次信任 提交于 2021-02-18 09:43:10
问题 I want to convert a date string to unix timestamp from a date string e.g. 14-02-2018 Can someone help? 回答1: Since JDK 8 you can do: val l = LocalDate.parse("14-02-2018", DateTimeFormatter.ofPattern("dd-MM-yyyy")) val unix = l.atStartOfDay(ZoneId.systemDefault()).toInstant().epochSecond Note that the example uses your system's default timezone. 回答2: use this to convert the date string to UNIX timestamp val date = SimpleDateFormat("dd-MM-yyyy").parse("14-02-2018") println(date.time) 来源: https:/

command to Substract two timestamps in unix

▼魔方 西西 提交于 2021-02-16 20:15:07
问题 I am writing a script and which requires to calculate the difference between the two timestamps . I have done some search but didn't get a clue so far. For Example say: time1 = 20160314 10:16:27 time2 = 20160313 15:17:28 From the above I need to get result like below: difference is: " 1 day 5 hours 1 minute 1 second " Please help me in resolving this. 回答1: datediff() { t1=$(date -d "$1" +%s) t2=$(date -d "$2" +%s) diff=$(( $t1 - $t2 )) echo "Duration: $(( $diff / 86400 )) days $(($diff / 3600

How to convert “2019-11-02T20:18:00Z” to timestamp in HQL?

拟墨画扇 提交于 2021-02-15 07:28:06
问题 I have datetime string "2019-11-02T20:18:00Z" . How can I convert it into timestamp in Hive HQL? 回答1: If you want preserve milliseconds then remove Z , replace T with space and convert to timestamp: select timestamp(regexp_replace("2019-11-02T20:18:00Z", '^(.+?)T(.+?)Z$','$1 $2')); Result: 2019-11-02 20:18:00 Also it works with milliseconds: select timestamp(regexp_replace("2019-11-02T20:18:00.123Z", '^(.+?)T(.+?)Z$','$1 $2')); Result: 2019-11-02 20:18:00.123 Using from_unixtime(unix

Mysql average value every minute refer to unix timestamp

做~自己de王妃 提交于 2021-02-11 14:28:03
问题 I logging my temperature every 1-3 seconds with unix timestamp, I wish like get row of data return by average every 1 minute period and last for 24 hour. my logger table look like this: unixtime temp 1350899052 25.37 1350899054 25.44 1350899057 25.44 1350899059 25.44 1350899062 25.44 1350899064 25.44 1350899069 25.44 1350899071 25.44 and i wish like it return as unixtime temp 1350899052 25.37 -- average value of 1 minute range both unixtime and temp 1350899054 25.44 1350899057 25.44 please

epoch with milliseconds to timestamp with milliseconds conversion in Hive

女生的网名这么多〃 提交于 2021-02-10 20:14:05
问题 How can I convert unix epoch with milliseconds to timestamp with milliseconds In Hive? Neither cast() nor from_unixtime() function is working to get the timestamp with milliseconds. I tried .SSS but the function just increases the year and doesn't take it as a part of millisecond. scala> spark.sql("select from_unixtime(1598632101000, 'yyyy-MM-dd hh:mm:ss.SSS')").show(false) +-----------------------------------------------------+ |from_unixtime(1598632101000, yyyy-MM-dd hh:mm:ss.SSS)| +-------

Python Numpy Loadtxt - Convert unix timestamp

。_饼干妹妹 提交于 2021-02-09 04:57:16
问题 I have a text file with many rows of data - the first piece of data in each row is a unix timestamp such as 1436472000 . I am using numpy.loadtxt and in the parameters for converters I want to specify for it to convert the timestamp into whatever numpy understands as a date time. I know this needs to go after the 0: in the curly brackets, but I can't work out how to convert it. I know a converter can be used from matplotlib.dates.strpdate2num for normal dates, but I this won't work for unix

How to convert time in utc second and timezone offset in second to date using java-8?

让人想犯罪 __ 提交于 2021-02-08 12:15:38
问题 I have a date in utc second and its time zone offset in sec. I would like to convert it to date string in format yyyy-mm-dd using java8 ZoneOffset class. Below is the time in seconds and offset long time = 1574962442, long offset = 3600 Now i want to obtain date in below format using java-8 DateTime API ? String date = 2019-11-28 // in yyyy-MM-dd 回答1: You can use Instant from java-8 DateTime API to obtains an OffsetDateTime of Instant from epoch seconds with offset seconds OffsetDateTime

Getting Date Time in Unix Time as Byte Array which size is 4 bytes with Java

◇◆丶佛笑我妖孽 提交于 2021-02-07 19:53:34
问题 How Can I get the date time in unix time as byte array which should fill 4 bytes space in Java? Something like that: byte[] productionDate = new byte[] { (byte) 0xC8, (byte) 0x34, (byte) 0x94, 0x54 }; 回答1: First: Unix time is a number of seconds since 01-01-1970 00:00:00 UTC. Java's System.currentTimeMillis() returns milliseconds since 01-01-1970 00:00:00 UTC. So you will have to divide by 1000 to get Unix time: int unixTime = (int)(System.currentTimeMillis() / 1000); Then you'll have to get

A Powershell function to convert unix time to string?

ε祈祈猫儿з 提交于 2021-02-07 19:51:00
问题 I'm trying to read the date fields of Firefox places.sqlite datedase using ADO.NET and PowerShell. Obviously these fields are in Unix time. I'm looking for a conversion to .Net datetime or string Edit: I want to bind the datarow to a WPF GridView. I need either a way to do the conversion within the SQL query or some way while binding the datarows to the grid. 回答1: Something like this should put you on the right path: [TimeZone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds(