momentjs

Convert Date to String in nested array in mongodb

好久不见. 提交于 2020-02-25 01:05:11
问题 I have a mongodb collection called cases and inside cases I have an array of cases per company object. So the structure is: Inside each case I want to use the createddate (which is a string) and endDate (also string) and convert it to a mongodb date. When I use NoSQLBooster I add the following query: db.cases.aggregate([ { $match: { companyID: 218 }}, { $unwind: "$cases" }, { $match: { 'cases.id': '299' }}, { $addFields: { 'cases.created': new Date('2010-06-21T00:00:00.000'), 'cases.closed':

How to format BC dates (like “-700-01-01”)?

纵饮孤独 提交于 2020-02-23 10:13:26
问题 How to format ISO dates BC with Moment.js? moment("-700-01-01").year(); // 700 (WRONG) moment("-0700-01-01").year(); // 700 (WRONG) moment("-000700-01-01").year(); // -700 (RIGHT) For some reason a year notation with 6 digits works. Is that the "right" way? Why doesn't notation like "-700-01-01" work? 回答1: This isn't a Moment.js-specific problem; the same happens if you attempt to initialise a Date() object with the string you're using as well. If you create it as a Date() object first and

Convert HH:mm into Moment.js

独自空忆成欢 提交于 2020-02-21 08:18:22
问题 So I have some time data such as follows: 10:45 PM 11:35 PM 12:06 AM 01:34 AM All of these times are in America/Los_Angeles and each time is guaranteed to be after 09:00 PM in today in that timezone. So that times which are past midnight take place tomorrow. Is there an elegant way to convert these times from the current format into moment.js objects with the times pinned to the appropriate day. 回答1: function getMomentFromTimeString(str) { var t = moment(str, 'HH:mm A'); // Now t is a moment

Convert HH:mm into Moment.js

做~自己de王妃 提交于 2020-02-21 08:16:13
问题 So I have some time data such as follows: 10:45 PM 11:35 PM 12:06 AM 01:34 AM All of these times are in America/Los_Angeles and each time is guaranteed to be after 09:00 PM in today in that timezone. So that times which are past midnight take place tomorrow. Is there an elegant way to convert these times from the current format into moment.js objects with the times pinned to the appropriate day. 回答1: function getMomentFromTimeString(str) { var t = moment(str, 'HH:mm A'); // Now t is a moment

React-Datepicker MomentJS Invalid Date

和自甴很熟 提交于 2020-02-20 08:33:19
问题 I'm using React-Datepicker and MomentJS. But when I want to use Moment for setting a startDate, the value gives Invalid date in the datepickerfield. When I log the this.state.startDate in the console, the console shows me the following: "startdate: 27-11-2018", this has the format 'DD-MM-YYYY'. This format is also used for the DatePicker component. import * as React from "react"; import * as ReactDOM from "react-dom"; import DatePicker from "react-datepicker"; import "react-datepicker/dist

How to obtain a list of available locale keys from momentjs with locale?

老子叫甜甜 提交于 2020-02-20 07:12:32
问题 I'd like to obtain the list of available locale keys. I can't find any documentation on how to do this. 回答1: en = English af = Afrikaans ar-dz = Arabic (Algeria) ar-kw = Arabic (Kuwait) ar-ly = Arabic (Libya) ar-ma = Arabic (Morocco) ar-sa = Arabic (Saudi Arabia) ar-tn = Arabic (Tunisia) ar = Arabic az = Azerbaijani be = Belarusian bg = Bulgarian bm = Bambara bn = Bengali bo = Tibetan br = Breton bs = Bosnian ca = Catalan cs = Czech cv = Chuvash cy = Welsh da = Danish de-at = German (Austria)

How to obtain a list of available locale keys from momentjs with locale?

|▌冷眼眸甩不掉的悲伤 提交于 2020-02-20 07:11:47
问题 I'd like to obtain the list of available locale keys. I can't find any documentation on how to do this. 回答1: en = English af = Afrikaans ar-dz = Arabic (Algeria) ar-kw = Arabic (Kuwait) ar-ly = Arabic (Libya) ar-ma = Arabic (Morocco) ar-sa = Arabic (Saudi Arabia) ar-tn = Arabic (Tunisia) ar = Arabic az = Azerbaijani be = Belarusian bg = Bulgarian bm = Bambara bn = Bengali bo = Tibetan br = Breton bs = Bosnian ca = Catalan cs = Czech cv = Chuvash cy = Welsh da = Danish de-at = German (Austria)

How to get selected date from ionic-2 calendar onchange() method

微笑、不失礼 提交于 2020-02-06 07:30:47
问题 I am using ion2-calendar. this is my html: <ion-calendar [(ngModel)]="date" (onChange)="onChange($event)" [type]="type" [format]="'YYYY-MM-DD'"> </ion-calendar> and this is onchange in ts: onChange($event) { console.log("onchange event called"); console.log(moment().format('DD-MM-YYYY')); } This is my console: onSelect event called 25-06-2018 But i am always getting current month and year,no matter which date I choose. Only the date value is changing. Its showing current month and year in the

TypeScript extend third party library moment.js

爱⌒轻易说出口 提交于 2020-02-03 09:48:09
问题 I simply want to add a function to the prototype of the Moment interface which will format always the same way whenever used. I tried already what can be found here. declare module moment { export interface Moment { myFormat: () => string; } } And in some other file, the implementation: Moment.prototype.myFormat = ():string => { return this.format("DD.MM.YYY"); } However, this is not working. I simply want to be able to call moment(aDate).myFormat() but I don't get it to work. Already tried

TypeScript extend third party library moment.js

天涯浪子 提交于 2020-02-03 09:47:51
问题 I simply want to add a function to the prototype of the Moment interface which will format always the same way whenever used. I tried already what can be found here. declare module moment { export interface Moment { myFormat: () => string; } } And in some other file, the implementation: Moment.prototype.myFormat = ():string => { return this.format("DD.MM.YYY"); } However, this is not working. I simply want to be able to call moment(aDate).myFormat() but I don't get it to work. Already tried