datetime-conversion

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

Convert ZonedDateTime to LocalDateTime at time zone

微笑、不失礼 提交于 2019-12-03 10:42:47
I have an object of ZonedDateTime that is constructed like this ZonedDateTime z = ZonedDateTime.of(LocalDate.now().atTime(11, 30), ZoneOffset.UTC); How can I convert it to LocalDateTime at time zone of Switzerland? Expected result should be 16 april 2018 13:30 . How can I convert it to LocalDateTime at time zone of Switzerland? You can convert the UTC ZonedDateTime into a ZonedDateTime with the time zone of Switzerland, but maintaining the same instant in time, and then get the LocalDateTime out of that, if you need to. I'd be tempted to keep it as a ZonedDateTime unless you need it as a

Java Converting 19-digit Unix Timestamp to a Readable Date

喜欢而已 提交于 2019-12-02 13:13:10
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 approach of achieving this: String timeStamp = "1558439504711000000"; long unixNanoSeconds = Long.parseLong

How to handle MySQL timezone in script

↘锁芯ラ 提交于 2019-12-02 05:19:50
I am developing a mobile application. From the application calls are made to a web service which runs different queries based on mode (?mode=xx) In some of those queries I use date functions like DATE(NOW()). The data stored in the MySQL database is stored in GMT-7 (Mountain Time Canada). I have yet to register a domain/host for this web service but when I do lets say it is hosted in a different city such as Toronto (which is GMT-5 - 2 hours ahead). Then at 10:05pm Mountain Time Canada a user uses the application to send a web request call which has a query like: SELECT DATE(NOW()) Because the

pandas convert from datetime to integer timestamp

二次信任 提交于 2019-12-01 21:07:56
Considering a pandas dataframe in python having a column named time of type integer, I can convert it to a datetime format with the following instruction. df['time'] = pandas.to_datetime(df['time'], unit='s') so now the column has entries like: 2019-01-15 13:25:43 . What is the command to revert the string to an integer timestamp value (representing the number of seconds elapsed from 1970-01-01 00:00:00 )? I checked pandas.Timestamp but could not find a conversion utility and I was not able to use pandas.to_timedelta for this. Is there any utility for this conversion? You can typecast to int

How to determine if the specific time is between given time range in javascript

狂风中的少年 提交于 2019-12-01 06:03:48
i want to check var check_val in between two time var open_time and var close_time var open_time = "23:30"; var close_time = "06:30"; var check_val ="02:30"; if(Date.parse ( check_val ) > Date.parse ( open_time ) && Date.parse ( check_val ) < Date.parse ( close_time )){ var flag=1; } else { var flag=2 } the result is always else part Date.parse() accepts dates in RFC2822 or ISO8601 formats. In your case, it always returns NaN . Date.parse("23:30"); // NaN Using the appropriate Date format works as expected: var open_time = Date.parse("2011-10-09T23:30"); var close_time = Date.parse("2011-10

How to determine if the specific time is between given time range in javascript

折月煮酒 提交于 2019-12-01 03:23:22
问题 i want to check var check_val in between two time var open_time and var close_time var open_time = "23:30"; var close_time = "06:30"; var check_val ="02:30"; if(Date.parse ( check_val ) > Date.parse ( open_time ) && Date.parse ( check_val ) < Date.parse ( close_time )){ var flag=1; } else { var flag=2 } the result is always else part 回答1: Date.parse() accepts dates in RFC2822 or ISO8601 formats. In your case, it always returns NaN . Date.parse("23:30"); // NaN Using the appropriate Date

PHP intl can convert a Gregorian date to other calendar type

烂漫一生 提交于 2019-11-30 09:37:41
问题 PHP intl can convert a Gregorian date to other calendar type. For example Gregorian to Hijri, 2017/04/11 to 1396/01/22 Or we must use external library to convert dates? 回答1: You Can Use This Method: function getDateTimeFromCalendarToFormat($format = 'yyyy-MM-dd HH:mm:ss', $time = null, $locale = 'fa_IR', $calendar = 'persian', $timeZone = 'Asia/Tehran') { if (empty($time)) { $time = new \DateTime(); } $formatter = new \IntlDateFormatter("{$locale}@calendar={$calendar}", \IntlDateFormatter:

DB2 timestampdiff function returning unexpected results

…衆ロ難τιáo~ 提交于 2019-11-30 09:17:29
问题 I'm using the following syntax TIMESTAMPDIFF(2, CHAR(CREATED - TIMESTAMP('1970-01-01 00:00:00')) where CREATED is of type TIMESTAMP and the database is DB2. The intension is to get the timestamp converted to millis from epoch. If there is a better function that would be more helpful. Sample data: For 2011-10-04 13:54:50 returned value is 1316613290 but actual value should be 1317732890 (got from http://www.epochconverter.com) Query to run SELECT TIMESTAMPDIFF(2, CHAR(TIMESTAMP('2011-10-04 13

PHP intl can convert a Gregorian date to other calendar type

╄→尐↘猪︶ㄣ 提交于 2019-11-29 15:32:13
PHP intl can convert a Gregorian date to other calendar type. For example Gregorian to Hijri, 2017/04/11 to 1396/01/22 Or we must use external library to convert dates? You Can Use This Method: function getDateTimeFromCalendarToFormat($format = 'yyyy-MM-dd HH:mm:ss', $time = null, $locale = 'fa_IR', $calendar = 'persian', $timeZone = 'Asia/Tehran') { if (empty($time)) { $time = new \DateTime(); } $formatter = new \IntlDateFormatter("{$locale}@calendar={$calendar}", \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, $timeZone, \IntlDateFormatter::TRADITIONAL); $dateArray = []; $formatter-