momentjs

Ion Range Slider with HH:mm format From & To not working

风格不统一 提交于 2021-01-29 05:23:00
问题 I am trying to use Ion Range Slider in my project to select working hours. Ex: (08:00-19:00). $('#ion').ionRangeSlider({ grid: false, type: 'double', min: moment("0000", "hhmm"), max: moment("2359", "hhmm"), from: moment("0800", "hhmm"), to: moment("1900", "hhmm"), force_edges: true, drag_interval: true, step: 3600000, min_interval: 3600000, prettify: function (num) { return moment(num).format('HH:mm'); } }); When i want to set default working hours using from & to, it doesn't work. Slider

moment-timezone setDefault not behaving as expected

那年仲夏 提交于 2021-01-29 04:48:08
问题 Using the following code: console.log(moment().toJSON()); moment.tz.setDefault("Europe/Brussels"); console.log(moment().toJSON()); I get the following result: 2019-05-12T10:39:12.851Z 2019-05-12T10:39:12.863Z However, when I read the documentation of moment-timezone, setDefault is supposed to set my default timezone on "Europe/Brussels", so the output should be: 2019-05-12T10:39:12.851Z 2019-05-12T11:39:12.863Z Apparently, setDefault cannot be used to what I want (which is generating a new

How can I stop getting an invalid date in IE with moment.js?

喜欢而已 提交于 2021-01-29 02:04:55
问题 This always returns "invalid date". It works in Chrome and Safari, but in IE I always get an invalid date. The code in question: var utcMoment = moment.utc(value.Timestamp); value.Timestamp is in this format: "17 Sep 15 19:55:37" Should I be using a different date format? I am unsure how to proceed. 回答1: You can explicitly define the format when creating the moment. var utcMoment = moment.utc("17 Sep 15 19:55:37", "DD MMM YY HH:mm:ss"); console.log(utcMoment); <script src="https://cdnjs

How to get list of days for last month, last three months in MomentJS

独自空忆成欢 提交于 2021-01-28 13:33:16
问题 Using moment().subtract(1, 'days').format("YYYY-MM-DD") i can get last x days from the current date. So how can i get all days from last month or last three months..? 回答1: If I understand your question correctly, this can be achieved via two steps. First calculate the moment that marks the starting date of the prior month: var prevMonth = moment().subtract(1, 'month').startOf('month'); var prevMonthDays = prevMonth.daysInMonth(); Then, iterate over the range 0...prevMonthDays , caclulating

Convert a time to a specific timezone in moment timezone

左心房为你撑大大i 提交于 2021-01-28 09:35:30
问题 I have a date 2018-06-19 09:06:29 . It is how it is stored in the database. I am using moment-timezone and calling this function. function getDateString(t, tz) { return moment() .tz("America/Chicago") .format('l'); } Here I know that my timezone is "America/Chicago" and it is "UTC-5 hours". I should get the time 5 hours before the time that I have passed as an argument. This function was working perfectly until I upgraded my react. Can anyone know what might be the issue? These are my current

Angular Chart.js - Remove Moment.js as Dependency / Reduce Bundle Size

泄露秘密 提交于 2021-01-28 02:06:40
问题 I am using Chart.js with Angualar 7 . But Chart.js adds about 450KB to my bundle size. Through other resources I found out, that Moment.js is the main factor for the big size. "chart.js": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-2.7.3.tgz", "integrity": "sha512-3+7k/DbR92m6BsMUYP6M0dMsMVZpMnwkUyNSAbqolHKsbIzH2Q4LWVEHHYq7v0fmEV8whXE0DrjANulw9j2K5g==", "requires": { "chartjs-color": "^2.1.0", "moment": "^2.10.2" } }, I want to know how to remove moment

fullcalendar confusion with UTC and local date

此生再无相见时 提交于 2021-01-27 11:41:44
问题 I do let fullcalendar initialize normally. So it represents current date. (Midnight->midnight, 1day, 1h slots) From some other datasource I get data with timestamps. The format is "YYYY-MM-DD HH:mm" (transmitted as a string, no timezone information) So I convert that string to a moment object and test against fullcalendar.start and .end to see if it is within. moment("2016-04-07 00:00") == $('#calendar').fullCalendar('getView').end This results in false though the following command $('

fullcalendar confusion with UTC and local date

若如初见. 提交于 2021-01-27 11:41:12
问题 I do let fullcalendar initialize normally. So it represents current date. (Midnight->midnight, 1day, 1h slots) From some other datasource I get data with timestamps. The format is "YYYY-MM-DD HH:mm" (transmitted as a string, no timezone information) So I convert that string to a moment object and test against fullcalendar.start and .end to see if it is within. moment("2016-04-07 00:00") == $('#calendar').fullCalendar('getView').end This results in false though the following command $('

fullcalendar confusion with UTC and local date

删除回忆录丶 提交于 2021-01-27 11:40:47
问题 I do let fullcalendar initialize normally. So it represents current date. (Midnight->midnight, 1day, 1h slots) From some other datasource I get data with timestamps. The format is "YYYY-MM-DD HH:mm" (transmitted as a string, no timezone information) So I convert that string to a moment object and test against fullcalendar.start and .end to see if it is within. moment("2016-04-07 00:00") == $('#calendar').fullCalendar('getView').end This results in false though the following command $('

moment.js gives invalid date in firefox, but not in chrome

此生再无相见时 提交于 2021-01-27 05:27:38
问题 I'm having a strange issue with moment.js. I wrote a function to convert the time from utc to german time format, and everything seemed to work just fine in chrome. But now I tried it with firefox and here I got an invalid date. moment.locale("de"); $('#from').datepicker({ format: "DD. MMMM YYYY" }); $('#from').on('change',function() { var a = moment($('#from').val(), "DD. MMMM YYYY").format("LLLL"); var b = moment(a).add(7,'days'); var localTime = moment.utc(b).toDate(); localTime = moment