momentjs Questions

3

Solved

I am using 2.22.1 to format dates. When i put in a date that comes from a date selector, moment will put the date back one day. For example, when I try to format a date in the following way: Exam...
Divers asked 22/5, 2018 at 18:5

4

Solved

I'm using DatePicker from MUI v6 (https://mui.com/x/react-date-pickers/date-picker/). And currently I've noticed that weeks in the calendar start with Sunday but I need them to start with Monday. A...
Caulis asked 14/4, 2023 at 13:57

6

Solved

I am using momentjs but having an issue trying to convert a UTC time to a specific timezone (not necessarily local to the current user) that is specified by name 'America/New_York'. This SO questio...
Upi asked 20/4, 2017 at 17:9

3

Solved

I have a string like : var from = '2016-06-06T21:03:55' ; Now how do I convert it into a timestamp such that I can give it as an input to momentjs. Basically, I want to find the difference in ...
Nonscheduled asked 9/5, 2016 at 23:22

6

Solved

I've two javascript variables: startDate and endDate. I want to store the current time(unix timestamp in ms) to endDate and timestamp of 24 hours before in startDate. I'll use this two variables to...
Wilhelmstrasse asked 5/4, 2015 at 6:38

2

Solved

I am using this code to fetch the GMT difference for a specific time zone: var TimeZone = 'America/New_York'; console.log('GMT Offset ' + moment().tz(TimeZone).utcOffset().toString()); Would thi...
Hostess asked 4/12, 2018 at 18:12

7

var timeArr = moment().format('HH:mm:ss').split(':'); var timeInMilliseconds = (timeArr[0] * 3600000) + (timeArr[1] * 60000); This solution works, test it, but I'd rather just use the moment api...
Growler asked 11/10, 2016 at 15:16

5

Solved

I have a TypeScript React app using npx create-react-app --template typescript. When I run npm start, I get an error in one of my files: TypeScript error in /<path>/App.tsx: Cannot find modu...
Corollary asked 1/5, 2020 at 5:54

5

I want to use Moment's guess() function to return the timezone continent (or country) and city as in their example: moment.tz.guess(); // America/Chicago But the above doesn't work. The returned...
Cloraclorinda asked 7/10, 2017 at 14:41

10

Solved

I have a string in this format: var testDate = "Fri Apr 12 2013 19:08:55 GMT-0500 (CDT)" I would like to use Moment.js get it in this format mm/dd/yyyy : 04/12/2013 for display. I tried ...
Punctual asked 13/4, 2013 at 23:8

4

Solved

I'm currently using moment.js to handle the displaying of time in a node.js application - is there a way I can ALWAYS have the date formatted with leading zeroes, and atleast two characters wide? ...
Retardment asked 7/12, 2016 at 14:4

32

Solved

Is there any way I can use the moment.js format method on duration objects? I can't find it anywhere in the docs and it doesn't seen to be an attribute on duration objects. I'd like to be able to d...
Consulate asked 7/11, 2012 at 3:13

3

Solved

I have epoch time stamp value and I want to extract the Time from it. For example: input 1480687432 i.e.(Fri Dec 02 2016 14:03:52 GMT+0530 (IST)) output 14:03:52, I want to compare it with sunset/s...
Saturday asked 2/12, 2016 at 8:41

6

My project is a react project. My website is a mutilanguage website, when I change the web language. moment.locale(lang) not working. My code is: const startDate = moment.utc(start).locale(lang...
Chelyabinsk asked 12/4, 2018 at 4:54

10

Solved

I have two moment dates: var fromDate = moment(new Date('1/1/2014')); var toDate = moment(new Date('6/1/2014')); Does moment provide a way to enumerate all of the dates between these two dates? ...
Sherellsherer asked 21/5, 2014 at 23:30

5

Solved

I'm trying to figure out the most optimal and with as minimum amount of loops way to group my array of js dates objects from this: (Take a note this is browser console output it's actully real JS d...
Glossator asked 8/8, 2015 at 5:44

19

Solved

I'm getting a warning that a value provided to moment is not in a recognized ISO format. I changed my variable today with the moment function and still it doesn't work. Here's the warning error: D...
Together asked 11/10, 2016 at 2:22

3

Solved

Trying to migrate from Moment.js to Dayjs but the only thing I can't get working is the Timezone abbreviation. dayjs('2020-07-06T14:30:00.000-04:00').tz(dayjs.tz.guess()).format('Do MMM YYYY [at] H...
Lecithinase asked 20/9, 2020 at 8:22

10

Solved

I'm trying to sort dates in my datatable like DD/MM/YYYY (day, month, year) . I was following https://datatables.net/plug-ins/sorting/ . but all the date sorts seem to be deprecated and point to ...
Vedic asked 2/5, 2016 at 14:11

7

Solved

I want to parse the following string with moment.js 2014-02-27T10:00:00 and output day month year (14 march 2014) I have been reading the docs but without success http://momentjs.com/docs/#/parsing...
Interchange asked 4/3, 2014 at 22:42

9

Solved

I'm trying to detect with Moment.js if a given date is between two dates. Since version 2.0.0, Tim added isBefore() and isAfter() for date comparison. Since there's no isBetween() method, I though...
Bacillus asked 15/2, 2013 at 15:9

2

Let's say I have a date string 2015-02-01 - (1st Feb 2015) Today we have 2016-07-02 (2nd Jul 2016) We can easily see that the older date took place approximately 1 year and 5 months and 1 day ago...
Lederman asked 2/7, 2016 at 9:58

11

To use MomentJS in views/custom.ejs, what is the correct way (if any)? Server side routes/index etc we can easily use require('moment'); etc and it works fine. Server Side (EJS views) views/custo...
Tchad asked 9/10, 2012 at 7:24

7

Solved

How can i change the current date to this format(DD/MM/YYYY) using moment.js? I have tried below code. $scope.SearchDate = moment(new Date(), "DD/MM/YYYY"); But it's return 0037-11-24T18:30:00....
Prolonge asked 25/4, 2015 at 6:13

2

Solved

I have very simple problem, but couldn't find good simple DRY solution. I want to convert number of hours to HH:MM format. My try with Moment.js is: var hours = 10.5 var hour_string = moment(hours...
Validate asked 19/5, 2017 at 11:21

© 2022 - 2024 — McMap. All rights reserved.