momentjs

MomentJS Timezone is returning incorrect date and time

独自空忆成欢 提交于 2020-01-24 20:06:37
问题 I am using moment.js and moment-timezone-with-data.min.js to calculate the date time. The date / time I am using is as follows: var dGC2018 = moment('2018-04-04T18:00:00').tz("Australia/Queensland"); The date is 4th of April 2018. The time is 6PM. The timezone is Queensland. The output (using console.log) is: Thu Apr 05 2018 04:00:00 GMT+1000 (E. Australia Standard Time) {} This output can be found by outputting dCG2018 to the console.log and expanding the returned object to find the _d

TypeScript won't resolve external module (node.js)

China☆狼群 提交于 2020-01-23 05:52:05
问题 I would like to use moment.js in my node application, so I installed moment.js using node's package manager npm: npm install moment@2.4.0 Just to be on the safe side, I checked moment is not installed globally and the installed version is really version 2.4.0 (version 2.4.0 in order to use the correct d.ts file ...) require("moment").version Alright, seems to be good. I'm also using the latest version of TypeScript (0.9.5). So, now I added the following file to my projects root directory

Using moment.js in Angular 2 typescript application

本小妞迷上赌 提交于 2020-01-22 17:45:47
问题 I'm struggling in using moment.js library inside an Angular 2 Typescript app. Even after reading the answer to this question I can't get it to work. This is what I did so far: I installed moment.js using npm, so I can find the library under node_modules/moment/moment.js I configured System.js to retrieve moment library: System.config({ packages: { app: { format: 'register', defaultExtension: 'js' }, moment: { main: 'moment.js', type: 'cjs', defaultExtension: 'js' } }, map: { moment: 'node

Using moment.js in Angular 2 typescript application

感情迁移 提交于 2020-01-22 17:44:26
问题 I'm struggling in using moment.js library inside an Angular 2 Typescript app. Even after reading the answer to this question I can't get it to work. This is what I did so far: I installed moment.js using npm, so I can find the library under node_modules/moment/moment.js I configured System.js to retrieve moment library: System.config({ packages: { app: { format: 'register', defaultExtension: 'js' }, moment: { main: 'moment.js', type: 'cjs', defaultExtension: 'js' } }, map: { moment: 'node

Convert HH:MM:SS to seconds in momentjs

给你一囗甜甜゛ 提交于 2020-01-22 08:56:52
问题 I have a string with 12 hour formatted time only var time="12:10:12: PM" I want to convert this string to seconds. how can i do this in moment.js ? 回答1: Try something like this: moment('12:10:12: PM', 'HH:mm:ss: A').diff(moment().startOf('day'), 'seconds'); returns 43812 回答2: I was just trying to achieve the same thing. using https://momentjs.com/ This is how I got what I wanted (03:11:23 => 11483 seconds) myVar = moment.duration(myVar).asSeconds() 来源: https://stackoverflow.com/questions

Convert HH:MM:SS to seconds in momentjs

旧时模样 提交于 2020-01-22 08:56:07
问题 I have a string with 12 hour formatted time only var time="12:10:12: PM" I want to convert this string to seconds. how can i do this in moment.js ? 回答1: Try something like this: moment('12:10:12: PM', 'HH:mm:ss: A').diff(moment().startOf('day'), 'seconds'); returns 43812 回答2: I was just trying to achieve the same thing. using https://momentjs.com/ This is how I got what I wanted (03:11:23 => 11483 seconds) myVar = moment.duration(myVar).asSeconds() 来源: https://stackoverflow.com/questions

react-moment where to set moment.locale

≡放荡痞女 提交于 2020-01-21 12:06:51
问题 After reading react-datepicker doc's I have tried changing my date picker language as the doc's instructions: Globally by calling moment.locale(lang) Picker-specific by providing the locale prop My question is where to write this setting in a react app. 1- app.js (constructor). 2- date-picker component(constructor). 3-somewhere else... And how to set it as prop, I have tried : <DatePicker locale='gr' minDate={this.props.minDate} selected={this.state.startDate} onChange={this.handleChange}

Get last monday in month in moment.js

人盡茶涼 提交于 2020-01-21 06:49:06
问题 Is there a way that I get the last monday in the month with moment.js? I know I can get the end of the month with: moment().endOf('month') But how about the last monday? 回答1: you get always monday with isoweek: moment().endOf('month').startOf('isoweek') 回答2: You're almost there. You just need to add a simple loop to step backward day-by-day until you find a Monday: result = moment().endOf('month'); while (result.day() !== 1) { result.subtract(1, 'day'); } return result; 回答3: moment().endOf(

boostrap3 bootstrap-datetimepicker.min.js设置中文语言

耗尽温柔 提交于 2020-01-17 20:28:13
问题 bootstrap3中使用bootstrap-datetimepicker遇到设置中文语言的问题 解决办法 bootstrap-datetimepicker在使用的时候要先引入 momentjs 中的moment.js默认显示英文. 想要显示中文可以通过在 momentjs 下载引用moment-with-locales.min.js来设置语言. 由于moment-with-locales.min.js文件太大,所有选择引入中文语言包 github地址 在locale中找到zh-cn.js <!--bootstrap 时间控件 --> <link rel="stylesheet" href="bootstrap-timepicker.min.css"/> <script src="moment.min.js"></script> <script src="bootstrap-datetimepicker.min.js"></script> <script src="zh-cn.js"></script> <script> $('#date-timepicker').datetimepicker({ locale: moment.locale('zh-cn') //引入中文语言 ... }) </script> 总结 省略了一些bootstrap主要相关css,js文件

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

谁都会走 提交于 2020-01-17 14:45:13
问题 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 }