timezone

Converting timezones in javascript resulted in very strange results, am I doing something wrong or is it a bug?

流过昼夜 提交于 2021-02-11 12:33:34
问题 After isolating the problem in my current project .... I think something is not working currently with the Date object in javascript. But I don't want to be arrogant because maybe I am doing something wrong, is it a bug? or am I doning something wrong? I want to convert a date to diffrent time zone in javascript, I made this function: function ConvertToTimeZone(date, timezone) { let convertedTimeString = date.toLocaleString("en-US", {hour12: false, timeZone: timezone}) return new Date

moment.js: Deprecation warning: value provided is not in a recognized RFC2822 or ISO format [duplicate]

浪尽此生 提交于 2021-02-11 12:16:55
问题 This question already has answers here : Deprecation warning in Moment.js - Not in a recognized ISO format (9 answers) Closed 1 year ago . I am getting date as input from an external source and it is a string, const a = '08-01-2019'; And required format for me is 'MM-DD-YYYY', const outputDateFormat = 'MM-DD-YYYY'; And I am using moment.js and doing below manipulations on that date like adding a year and decreasing a day, //adding a year const a = moment(a).add(1, 'years').add(-1, 'days')

Rails datetime_select with time zone

拟墨画扇 提交于 2021-02-10 22:20:32
问题 I am writing a simple calendar app and having troubles with time zones. For as many nice Date and Time helpers, action view and active record sure don't play nice with time zones. I have an appointment model with the appointment_time attribute which is a datetime. My current issue is editing appointment_time with datetime_select within a form tag. <%= datetime_select :appointment_time, @appt.appt_time,ampm: true %> def appt_time appointment_time.in_time_zone(time_zone) #this is the

When date only is required to save, Converting it to UTC and then to local may behave differently in different time zones

假如想象 提交于 2021-02-10 19:52:54
问题 I have a date field at front end. And I am saving it from a time zone say 19/04/2018 and I am on +8. When I load it on local datetime.ToLocalTime() works perfectly in +8 offset and it will show 19/04/2018 but a person sitting in +7 would get in 18/04/2018 23:00 and hence it will show 18/04/2018. How to handle this case. 回答1: In general: you should not convert date only to UTC, so you should keep it as local date. But it really depend on the use of data. If you are using for some

Strange behavior with pandas timestamp to posix conversion

谁说我不能喝 提交于 2021-02-10 18:41:49
问题 I do the following operations: Convert string datetime in pandas dataframe to python datetime via apply(strptime) Convert datetime to posix timestamp via .timestamp() method If I revert posix back to datetime with .fromtimestamp() I obtain different datetime It differs by 3 hours which is my timezone (I'm at UTC+3 now), so I suppose it is a kind of timezone issue. Also I understand that in apply it implicitly converts to pandas.Timestamp , but I don't understand the difference in this case.

Strange behavior with pandas timestamp to posix conversion

血红的双手。 提交于 2021-02-10 18:40:18
问题 I do the following operations: Convert string datetime in pandas dataframe to python datetime via apply(strptime) Convert datetime to posix timestamp via .timestamp() method If I revert posix back to datetime with .fromtimestamp() I obtain different datetime It differs by 3 hours which is my timezone (I'm at UTC+3 now), so I suppose it is a kind of timezone issue. Also I understand that in apply it implicitly converts to pandas.Timestamp , but I don't understand the difference in this case.

Java: Parse Date String with timezone abbreviations to Date object

馋奶兔 提交于 2021-02-10 15:24:19
问题 I need to parse a date string with timezone to Date object. The input date string pattern is: "MM/dd/yyyy hh:mm a z" (eg: 04/30/2018 06:00 PM IST). I have used below given code. But it returns incorrect date as output. new SimpleDateFormat("MM/dd/yyyy hh:mm a z").parse("04/30/2018 06:00 PM IST") Current Output: "Mon Apr 30 09:00:00 PDT 2018" . Expected Output: "Mon Apr 30 05:30:00 PDT 2018 . 回答1: That's because timezone's abbreviations such as IST are ambiguous. IST is used in India, Israel

Java: Parse Date String with timezone abbreviations to Date object

天大地大妈咪最大 提交于 2021-02-10 15:23:40
问题 I need to parse a date string with timezone to Date object. The input date string pattern is: "MM/dd/yyyy hh:mm a z" (eg: 04/30/2018 06:00 PM IST). I have used below given code. But it returns incorrect date as output. new SimpleDateFormat("MM/dd/yyyy hh:mm a z").parse("04/30/2018 06:00 PM IST") Current Output: "Mon Apr 30 09:00:00 PDT 2018" . Expected Output: "Mon Apr 30 05:30:00 PDT 2018 . 回答1: That's because timezone's abbreviations such as IST are ambiguous. IST is used in India, Israel

Java: Parse Date String with timezone abbreviations to Date object

浪尽此生 提交于 2021-02-10 15:23:02
问题 I need to parse a date string with timezone to Date object. The input date string pattern is: "MM/dd/yyyy hh:mm a z" (eg: 04/30/2018 06:00 PM IST). I have used below given code. But it returns incorrect date as output. new SimpleDateFormat("MM/dd/yyyy hh:mm a z").parse("04/30/2018 06:00 PM IST") Current Output: "Mon Apr 30 09:00:00 PDT 2018" . Expected Output: "Mon Apr 30 05:30:00 PDT 2018 . 回答1: That's because timezone's abbreviations such as IST are ambiguous. IST is used in India, Israel

Changing one date to another date format using LocalDate

若如初见. 提交于 2021-02-10 12:11:20
问题 I have the following input as a Map<String,String> 1) MM dd yyyy = 08 10 2019 2) dd MM yyyy = 10 05 2019 3) dd MM yyyy = 05 10 2008 4) yyyy dd MM = 2001 24 01 I want to convert all this dates to "yyyy-MM-dd" format Currently, i am using for (String eachFormat : formats) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(eachFormat); try { SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy-MM-dd"); Date inputDate = simpleDateFormat.parse(parsedDate.get(eachFormat)); return