momentjs

Subtracting hours from date string

一曲冷凌霜 提交于 2019-12-25 16:56:07
问题 I am working in node js and by using moment-timezone package I have generated a date: 2017-4-10 19:04:47 Below is the code I used to generate this date time which is for timezone Asia/shanghai: var momentTimezone = require('moment-timezone'); console.log(momentTimezone(new Date()).tz('Asia/shanghai').format('Y-M-D HH:MM:ss')); Now I want to subtract hours from this time to generate another date. I want to subtract 9940 hours. I have searched for many hours but could not find exact solution.

Disabling future date in daterange picker using moment.js

混江龙づ霸主 提交于 2019-12-25 11:14:12
问题 I have a daterange picker in my HTML file <input date-range-picker class="form-control date-picker" type="text" ng-model="datePicker.date" options="onApplyDateRange"/> I want to know that is it possible to validate it using moment.js .I have been trying to validate it but I'm not able to get it working. Please help I have used https://www.npmjs.com/package/angular-daterangepicker https://github.com/fragaria/angular-daterangepicker 回答1: you can try using max in the html and get the maxdate

Disabling future date in daterange picker using moment.js

别说谁变了你拦得住时间么 提交于 2019-12-25 11:12:12
问题 I have a daterange picker in my HTML file <input date-range-picker class="form-control date-picker" type="text" ng-model="datePicker.date" options="onApplyDateRange"/> I want to know that is it possible to validate it using moment.js .I have been trying to validate it but I'm not able to get it working. Please help I have used https://www.npmjs.com/package/angular-daterangepicker https://github.com/fragaria/angular-daterangepicker 回答1: you can try using max in the html and get the maxdate

JavaScript to check selected date is today's date and time is 2pm using Moment.js

三世轮回 提交于 2019-12-25 07:39:45
问题 How do I compare today's time and date with user selected date. If user selects today's date or tomorrow's date and time is 2pm or more than 2pm then I should show alert saying delivery time over. I have tried something like this $scope.checkDateTime=function(){ angular.forEach($scope.orders.start_date,function(s){ console.log(s); var curTime = moment().format('YYYY-MM-DD HH:mm:ss'); var orderTime = s+' 14:00:00'; console.log(moment(orderTime).diff(curTime,'seconds')); if(moment(orderTime)

Moment / Jquery - Silly issue with a simple timeline

我只是一个虾纸丫 提交于 2019-12-25 07:34:52
问题 I had alot of help from this community getting my timeline report to work correctly. The way this is setup is that it will get a date range by checking the ajax return. Then it will group all my entries by their day of the week. If there are no entries for a particular i that date range, then it will simply return "No entries today." Fo far everything is working and you can see the example below: https://jsfiddle.net/j3yg2j7j/7/ However I noticed that if the last day in the date range is

How to resolve loss of minute precision formatting a moment in 12HR?

拟墨画扇 提交于 2019-12-25 07:23:48
问题 I've converted an ISO date string to a momentjs moment and then formatted that moment using .format("MM/DD/YYYY HH:MM") . When I output the final formatted moment, the minute value is incorrect as against the value read back from the iso string originally. In this case the ISO string value holds 3:10 PM or "2016-08-03T03:10:00.000Z" as represented in the string. But when I call format the moment value is 4:07PM meaning three minutes have been subtracted during the format. During debug I noted

Filter out non-contiguous date using momentjs and twix.js

◇◆丶佛笑我妖孽 提交于 2019-12-25 06:09:33
问题 I want to find the last date that is contiguous with all the previous dates in a list. Pictorially: In the above picture I want the circled 'date'. I have a service that exposes a function (copied from memory, as I am not currently at work): var maxContiguousDates = function(listOfDates1, listOfDates2){ ranges = combineDatesIntoTwixRanges(listOfDates1, listOfDates2); //Sort with earliest start first sortedRanges = _.sortBy(ranges,function(range){return -range.start.unix()}) return moment.max

Filter out non-contiguous date using momentjs and twix.js

依然范特西╮ 提交于 2019-12-25 06:09:03
问题 I want to find the last date that is contiguous with all the previous dates in a list. Pictorially: In the above picture I want the circled 'date'. I have a service that exposes a function (copied from memory, as I am not currently at work): var maxContiguousDates = function(listOfDates1, listOfDates2){ ranges = combineDatesIntoTwixRanges(listOfDates1, listOfDates2); //Sort with earliest start first sortedRanges = _.sortBy(ranges,function(range){return -range.start.unix()}) return moment.max

Set specific time in specific timezone using momentjs

て烟熏妆下的殇ゞ 提交于 2019-12-25 05:24:18
问题 I am making a web-app and my users need to select a specific time in a specific time zone. For example, selecting 8th November 2013 at noon in New York City . Unfortunately, I cannot properly set the date in the momentjs object. Here is a jsfiddle that reproduces my problem. What am I doing wrong? var data = {date: 8, hour: 12, minute: 0, month: 10, year: 2013} var ret = moment({}).tz("America/New_York"); _.each(data, function(val,key){ ret.set(key, val); }); $("h1").text("the date should be

MongoDB + JS Date shifted -1 day

偶尔善良 提交于 2019-12-25 04:22:56
问题 I'm trying to add a new date inside my mongodb document using db.collection('course').insertOne({ date: new Date(item.date) }); item.date is from items.push({ date: moment(new Date(day.label)).tz('Europe/Paris').format('YYYY/MM/DD'), }); day.label is like '14 November 2016' item.date is formated like 2016/11/14 The document insert work but the dates are not properly formated, for example, for 2016/11/14 Mongo insert "date" : ISODate("2016-11-13T23:00:00Z") Every inserted dates are shifted -1