momentjs

Calling function at set intervals in React presentational component [duplicate]

放肆的年华 提交于 2020-01-17 14:45:06
问题 This question already has answers here : javascript setTimeout() not working [closed] (7 answers) setInterval/setTimeout return value (6 answers) Closed 2 years ago . I'm trying to implement a ticking timer using moment.js in my presenational React component. As a first step, I wanted to just call a function every second but instead of getting the text the function should return, I'm getting an int value. Any idea how I should implement this? Here's my component: import React, { PropTypes }

Momentjs Locale - Day of Week Config for US

丶灬走出姿态 提交于 2020-01-17 05:49:07
问题 I'm using Momentjs in several places in an App I'm working on, and it is working fine. However, I am using endOf('week') and it is resulting in Saturdays. What I am expecting is Sundays. I've been trying to find information about it, but it is not standing out anywhere how to get around it without changing code everywhere it is used. From my digging around, Moment automatically applies locales. And from looking in one of the locale files, I can see where this day of week (dow) is configured.

Create moment Object from UTC string

こ雲淡風輕ζ 提交于 2020-01-17 04:41:09
问题 I'm getting from my webservice an UTC date String such as the following : "2015-06-06T12:30:12Z" I need to display it following these 2 rules : If date < 1 week, display it like : 3 days ago or 23 mins ago.... If date > 1 week, display the date YYYY-DD-MM Now I'm trying to build a moment object but seems to be returning something weird : var sDate = "2015-06-06T12:30:12Z"; var momentDate = moment(sDate); var fromNow = momentDate.fromNow(); console.log("momentDate : " + momentDate); //

InvalidPipeArgument: '2017-12-05 05:30:00 for pipe 'DatePipe' - Safari

点点圈 提交于 2020-01-16 19:56:09
问题 Exception InvalidPipeArgument: '2017-12-05 05:30:00 for pipe 'DatePipe' Code The following code is working fine on mac machine chrome browser but in safari it fails : import { Pipe, PipeTransform } from '@angular/core'; import { DatePipe } from '@angular/common'; import * as moment from 'moment'; @Pipe({ name: 'dateCulturePipe', }) export class dateCulturePipe implements PipeTransform { transform(value: string) { if (value) { value = moment.utc(value).local().format('YYYY-MM-DD HH:mm:ss'); }

How can you retrieve multiple values with momentjs from firebase?

我是研究僧i 提交于 2020-01-16 19:31:52
问题 I get all data from firebase and store it on array and from that array i take all posted_at data (time when was something posted). My goal is to retrieve all that data in some sort of time format and problem is that it won't retrieve multiple values. I am using Vuejs. <template> <div v-for="data in array"> {{ time }} </div> </template> <script> import moment from 'moment' export default{ data(){ return{ array:[]//example:1577200868199, 1577200868189,... } }, computed:{ time(){ moment(this

x-Axis not working because I'm not using correctly moment.js

天大地大妈咪最大 提交于 2020-01-16 11:59:34
问题 I'm trying to plot some info, and my x-axis are time. For this objective I'm using, chart.js and moment.js but I'm having some problems to convert this time to a label. My code is: var sData = { datasets: [{ label: 'Dataset1', data: [{ x: '09:00', y: 88 }, { x: '09:10', y: 89 }, { x: '09:13', y: 86 }, { x: '09:23', y: 86 }, { x: '09:26', y: 85}, { x: '09:29', y: 83 }] }, { label: 'Dataset2', data: [{ x: '09:02', y: 88 }, { x: '09:13', y: 89 }, { x: '09:14', y: 86 }, { x: '09:20', y: 86 }, { x

Why are changing the time value of my axis (moment.js)?

我们两清 提交于 2020-01-16 08:37:16
问题 I am working with chart.js and moment.js to show a chart with x-axis as time. I had some problems with plotting this axis and I asked this question. @uminder solved it. This is his code, var sData = { datasets: [{ label: 'Dataset1', data: [{ x: '09:00', y: 88 }, { x: '09:10', y: 89 }, { x: '09:13', y: 86 }, { x: '09:23', y: 86 }, { x: '09:26', y: 85 }, { x: '09:29', y: 83 } ] }, { label: 'Dataset2', data: [{ x: '09:02', y: 88 }, { x: '09:13', y: 89 }, { x: '09:14', y: 86 }, { x: '09:20', y:

how to disable moment.js daylight timezone conversion

孤街浪徒 提交于 2020-01-14 19:26:07
问题 It is possible to disable the daylight timezone conversion in moment.js? http://plnkr.co/edit/MjFelt?p=preview $scope.obj.date = moment('2016-06-03T04:00:00.000Z'); Basically my application deals with events and dates only, but moment.js converting the daylight savings time is causing issue with dates. Does it have any setting which will disable it across the entire application usage? 回答1: If you are saying that you want moment to display your date and time (which is UTC, as indicated by the

Moment.js Get difference between two dates in the dd:hh:mm:ss format?

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-14 14:57:13
问题 I am calculating the time until 11:59PM of the current day. Here is an example. <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.js"></script> <script> setInterval(function() { var now = moment(); var mid = moment(); mid = mid.endOf('day'); var diffHours = mid.diff(now, 'hours'); var diffMinutes = mid.diff(now, 'minutes'); var diffSeconds = mid.diff(now, 'seconds'); console.log(diffHours + "h " + diffMinutes + "m " + diffSeconds + "s"); }, 1000) </script> However, I

How to get date without time in existing momentjs object?

萝らか妹 提交于 2020-01-12 15:17:50
问题 Let's say I have momentjs object like the following: var date = moment(new Date(2014,2,17,9,60)); How could I get clone and get new momentjs object without time? 回答1: With moment version 1.7 and above, just use startOf method. var date2 = date1.clone().startOf('day'); See http://momentjs.com/docs/#/manipulating/start-of/ 回答2: The momentjs object will always store a time, regardless of whether you use it. However, the following will clone date to date2 and reset the time: var date2 = date