momentjs

convert time of certain timezone to UTC using momemtjs

≡放荡痞女 提交于 2020-01-06 18:33:48
问题 I have a time in a specific timezone , I want to covert it to UTC . how can I achieve that using moment timezone ? http://momentjs.com/timezone/ in the documentation this is how to convert : jun.tz('America/Los_Angeles').format('ha z'); I am just not sure what timezone name to pass to convert it to UTC, or is there another function to use? 回答1: You can easily construct a moment in a specific time zone by using the moment.tz(...) syntax. This is slightly different from doing conversions with

Moment.js - Date comparison: Catching min range

给你一囗甜甜゛ 提交于 2020-01-06 18:13:37
问题 My form has a Kendo DatePicker and a button that runs a JavaScript function prior to doing a form.submit(). I need to be able to compare my date that is entered against a lower limit, and prevent the code from going on (submitting the form) if it is earlier than my set date. I want to return false if the limit hasn't been breached, true if it has. I'll use this example to show what I'm trying to do in the validation code: var lowerBound = new Date('1776', '6','4'); // July 4, 1776 var

MomentJS timestamp parsing shows wrong date

纵饮孤独 提交于 2020-01-06 09:02:34
问题 I am using moment JS in my Angular project and I tried to parse a timestamp I got from server. the problem is that moment outputs : January 18, 1970 4:03 PM for the timestamp : 1526636521 . which is not what I get form the online epoch converter. ( Friday, May 18, 2018 9:42:01 AM ) this is my moment call : moment.utc(data.TimeStamp).format('LLL') ; 回答1: As the number you are using is number of seconds from 1970 Jan 1st , moment.utc takes in number of milliseconds , So either use, moment.unix

Fullcalendar doesn't scoll to Current Date in timelineWeek view

主宰稳场 提交于 2020-01-06 07:15:20
问题 I have purchased the Fullcalendar license.But i'm facing issue as it doesn't scroll automatically to current date in timelineWeek,timelineMonth view.I have attached below the code snipet which I have tried. if $('#eventcalendarsub').length > 0 $('#eventcalendarsub,#eventcalendarsubbig').fullCalendar scrollTime: moment().subtract(3, 'h') disableDragging:true nowIndicator:true editable: false height: 390 header: left: 'today prev,next' center: 'title' right: 'timelineDay,timelineWeek

momentJS: Getting wrong timestamp from date in a different timezone

亡梦爱人 提交于 2020-01-05 06:54:06
问题 There is one time input i.e. start_time I am trying to get timestamp in milliseconds for these inputs let start_time = "17:05:00"; var start_date_moment = moment(start_time, "HH:mm:ss"); console.log(start_timestamp); output is -> moment("2019-04-24T17:05:00.000") This output remains same on server and local But when I am trying to get unix timestamp in milliseconds in the same way var start_timestamp = moment(start_time, "HH:mm:ss").valueOf(); On server at different timezone console.log(start

Moment.js and Chart.js not working in Firefox Addon when Type time is specified

旧城冷巷雨未停 提交于 2020-01-05 06:53:12
问题 I've created a firefox addon with: My manifest includes: "content_scripts": [ { "matches": [ "..." ], "js": [ "moment.js", "jquery.js", "chartjs.js", "main.js" ], "run_at": "document_end" } ] main.js includes: var myChart = new Chart(ctx, { type: 'line', data: { datasets: [{ label: label, lineTension: 0, backgroundColor: color, data: data }] }, options: { scales: { xAxes: [{ type: "time", distribution: 'linear', time: { unit: "day" } }] } } }); This works in my Chrome extension, but when I

datejavascript change a numeric value into time value

穿精又带淫゛_ 提交于 2020-01-05 03:36:43
问题 In JavaScript, jQuery, moment.js or any library, how would u change a numeric value like 116265 (11 hours, 62 minutes, 65 seconds) into the correct time value 12:03:05 ? Edit/Update: It must work also if the hours are bigger then 2 digits. (In my case the hours are the only part that can be bigger then 2 digits.) 回答1: Use replace() method with function console.log( '116265'.replace(/^(\d+)(\d{2})(\d{2})$/, function(m, m1, m2, m3) { m1 = Number(m1); // convert captured group value to number m2

Using Moment with Angular and TypeScript

╄→гoц情女王★ 提交于 2020-01-04 08:20:02
问题 I'm new to TypeScript and it's been a while since I've done any serious JavaScript development, so I may be missing something obvious. I'm trying to use Moment in an Angular 1 app with TypeScript. I'm using Angular 1.6.5, Moment 2.17.1 and TypeScript 2.17.1. I have Angular typings installed from the npm @types\angular package. Intellisense etc for Angular is working in VS Code. I've posted the sample code to GitHub here: https://github.com/kevinkuszyk/moment-angular-typescript The first error

How to format date in React material-ui date-picker?

我只是一个虾纸丫 提交于 2020-01-03 15:54:15
问题 I'm implementing redux-form with a material-ui date-picker field. Date is perfectly set in field but when I try to send it to the back-end API format of the date is: BeginDate_1: Tue Nov 14 2017 15:03:43 GMT+0530 (IST) I'm trying to change this format to 'YYYY-mm-dd' format before sending it to the the back-end API. I tried momentjs for formatting, but I couldn't get the result I wanted. Here's what I've tried: Home.js import React, {Component} from 'react'; import {Field, reduxForm} from

Chart.js moment locale

限于喜欢 提交于 2020-01-03 15:34:24
问题 I'm building an Angular 2 app and use Chart.js 2.0 to display 'time' data. Unfortunately I am not able to change the locale of moment.js. I npm installed moment and import moment.js and pl.js using SystemJS, but Chart.js complains that moment.js has to be loaded before Chart.js (not sure how to accomplish that, in every source file moment is declared before chartjs). Then I tried the Chart.bundle.min.js (with moment included), which works but only in english. I am not able to change the