Questions tagged [momentjs]

A JavaScript date library for parsing, manipulating, and formatting dates. Use this tag for issues with moment, moment-timezone, and any moment plugins. NOTE: As of September 2020, the Moment team recommends you chose a different library for new projects. See the Project Status section of the Moment docs. On StackOverflow, please refrain from recommending Moment as a solution unless Moment is specifically asked for in the question.

Filter by
Sorted by
Tagged with
0 votes
2 answers
40 views

How can i modify my date format like this: "month day, year"

i am getting a date with a format like this: const momentDate = localDate(date) return momentDate.format('LL') in english i am geting good "december 5, 2023" but in spanish that is ...
logger's user avatar
  • 11
-1 votes
0 answers
26 views

moment.js in client components: Module not found: Can't resolve 'fs'

I have the following helper method located at "@/utils/helper.ts" which formats dates using moment.js: export const formatDateTime = (date: Date): string => { return moment(date).format(...
Hassan Ali's user avatar
0 votes
0 answers
22 views

Convert between Gregorian and Hijri dates in Vue3 Component

I wrote a vue.js code component that shows two fields for the Hijri and Gregorian dates. When the user chooses the Gregorian date, the Gregorian to Hijri conversion function converts the value and ...
Programmer's user avatar
-3 votes
1 answer
57 views

One Datepicker value automatically in second datepicker?

I have a form having two fields of Calendar/Datepicker.. Field No.1 <div class="input-group date" id="gnd_institutiondate"> <input id="...
Saima Mushtaq's user avatar
0 votes
0 answers
35 views

Use MomentJS/Moment Timezone for the browsers specific Timezone (nodejs)

I am wondering if there is a way for it to find out what timezone you are in and output it in this code: const moment = require('moment'); function formatMessage(username, text) { return { ...
Alexander Coupe's user avatar
0 votes
1 answer
44 views

Cannot read properties of undefined (reading 'format') with NuxtJs

I all I have this problem with momentjs and NuxtJS I have created the composable with the javascript inside to get the current time in different place in the world. Than I have crated a components to ...
Federico's user avatar
0 votes
1 answer
36 views

import/order unable to recognise unnamed imports?

The specific rule import/order from eslint-plugin-import does not seem to recognise the unnamed imports such as import moment/locale/fr: to clarify, I need to import moment like this (as the ...
Thanh-Quy Nguyen's user avatar
0 votes
0 answers
16 views

POSIX epoch format to timezone using moment

I came across use where I'm getting time in POSIX epoch format. I want to convert it to local date of given timezone. but momentjs is giving different result. moment .unix(1700742300) .tz('America/...
sujit kolte's user avatar
0 votes
1 answer
52 views

How to handle turn of the year logically with moment.js?

Basically, I'm having a dynamic dropdown with x isoWeeks starting from the current one. A function is called when the isoWeek in the dropdown is selected. var currentWeek = localStorage.getItem('...
Phil-Absynth's user avatar
-1 votes
1 answer
51 views

fullcalendar adds 1 more day to my date selection

I'm stuck on a calendar problem. I use FullCalendar to select a range of dates. Example when I select from 11/20/23 to 11/22/23. Fullcalendar adds 1 more day (see screen). this is the result when I ...
Christopher's user avatar
0 votes
1 answer
28 views

Unable to add 5 days to current date using calender

I am trying to pass 2 props to a function, the minDate is to take the current date. The maxDate should take 5 days from today. But the minDate and maxDate are not getting calculated. minDate={moment()....
Purva Parulekar's user avatar
-1 votes
2 answers
68 views

Mongoose model saves default date as that of last time the server was started at

I have this mongoose model const reportUsSchema = new mongoose.Schema({ texts: [ { text: { type: String, default: "" }, date_time: { type: Date, default: new Date() }, }...
ARHAM RUMI's user avatar
0 votes
1 answer
69 views

Moment js is not converting as expected to utc time format "11/08/2023 11:03:00" to "2023-08-11 16:33:07"

Moment js is not converting as expected to utc time format "11/08/2023 11:03:00" to "2023-08-11 16:33:07" tired with let ScheduledStartDate = "11/08/2023 11:03:00"; let ...
Anandeva's user avatar
  • 162
0 votes
3 answers
60 views

Moment.tz("Europe/Berlin").startOf("week") returning Sunday instead of Monday

Certain timezones start the week on a Monday rather than Sunday, f.e. Germany. I expected Moment.tz("Europe/Berlin").startOf("week") to return Monday but instead it returns Sunday. ...
user17443811's user avatar
0 votes
0 answers
34 views

How to restore full array again after splice an element by condition?

I have a dynamic table and want to have a random array element for each day of a month. For each day I might need to remove an array element by condition, but I need to have the original array again ...
Phil-Absynth's user avatar
-1 votes
1 answer
81 views

what's wrong with format moment js?

we have 2 isoString dates: startedAt: '2023-10-18T14:03:36.150Z', closedAt: '2023-10-18T18:13:33.150Z' When I'm taking duration differences it's working good: const duration = moment.duration(moment(...
Daniyar Changylov's user avatar
0 votes
1 answer
62 views

Moment.js (Relative time)

I'm building a social network app using react.js, I'm using moment.js to get relative time when a user add a post it should be on that behavior : a few seconds ago 1 minute ago 2 minutes ago and so on ...
tabet's user avatar
  • 1
0 votes
1 answer
43 views

Validate date fromat with timezone in javascript

I am trying to validate the date(2022-08-28T14:35:02.439Z) given in this format, If i try to change the format it should throw error as invalid. I have checked with below code, it is retruning IST ...
Test1234's user avatar
  • 399
0 votes
0 answers
41 views

updating my project to latest bootstrap and jquery

I want to update few technologies in my project like:- Jquery Bootstrap moment jquery ui to its current latest respective versions. I am not able to figure out that which technology should I update ...
Kiran Kumari's user avatar
0 votes
0 answers
43 views

Data in dygraphs legend not displaying on mouse hover over

I am experiencing strange behaviour when launching a shiny application which has two dyGraphs. The data displayed on the legend does not appear on mouse hover over. My limited JS understanding is that ...
AE738's user avatar
  • 33
0 votes
0 answers
64 views

How to filter rooms by date range in React, Node.js, and Mongoose?"

I am trying to create a functionality to filter rooms by date range in [React], [Node.js], and [Mongoose]. I have a list of rooms and I want to be able to filter them based on the check-in and check-...
PRANJAL CHAURSIYA's user avatar
0 votes
0 answers
33 views

code to find time until next business opening hour

I am currently using momentjs in my typescript/node code where, given a current time given by const currentTime = moment(), I wish to find the time until the next business opening hour. The business ...
Sabo Boz's user avatar
  • 2,005
0 votes
1 answer
37 views

Angular String to Date object with ignoring timezone

my portal consists of multiple country and the data retrieved from the datalake is in UTC timezone. So whenever the user try to navigate in one of page in the portal of the specific country. The ...
MYTH JENKEN's user avatar
0 votes
1 answer
63 views

moment.js not taking UTC timezone

I'm using moment.js to convert the time to different timezone, but the time it is taking intially is not being treated as UTC even after specifying it. moment.utc(dateMillis).tz(timezone).format(...
geekynoob's user avatar
0 votes
0 answers
35 views

Deprecation warning when converting moment from require to import

I have been using moment within my React project previously by including it with const moment = require('moment'); and it has worked without issue for as long as I can remember. const moment = require(...
physicsboy's user avatar
  • 5,794
0 votes
1 answer
52 views

Using a Global Initial Date with Moment.js in a React Native Application

In our React Native application, we're using moment.js for various date and time manipulations. However, we need to set a global initial date and time, which should be used throughout the entire ...
Cemil CANLI's user avatar
1 vote
1 answer
43 views

Moment.js shows 00/Fr/2021 [closed]

I am trying to change the format of the date using below React function below. The date that I am passing is 2021-12-31 My function is like below export const getDate = (date) => { if (date?....
Purva Parulekar's user avatar
0 votes
0 answers
17 views

moment-timezone gives inconsistence timezone abbrevation

I'm experiencing inconsistent timezone abbreviations when using Moment-Timezone: Case 1: When I use moment('2023-09-21T22:37:17.972Z').tz('Asia/Singapore').format('M/D/YY h:mm A (z)'), I get '9/22/23 ...
suraj.tripathi's user avatar
3 votes
1 answer
174 views

Valid Hijri Date shown as invalid in moment-hijri

According to the ummul-qura site, 30-Shawwal-1400 is a valid date , but it is returned as invalid when passed throught isValid function using moment-hijri plugin moment('1400-10-30', 'iYYYY-iMM-iDD')....
Zuhair's user avatar
  • 277
0 votes
1 answer
118 views

Parse date dd/MM/yyyy don't work for me with dayjs or date_fns

I willed replace momentjs by dayjs (or date-fns). On my example I have this error Invalid Date for a variable: <html> <head> <script src="https://cdn.jsdelivr.net/npm/dayjs@1/dayjs....
Heliospeed's user avatar
1 vote
1 answer
59 views

horizontal bar chart with time: tooltip only works with last item

I'm currently trying to recreate a machine timeline using chart-js and momentum. The current state already looks like the original, but there are some points that are not working as expected. the ...
ITGuy's user avatar
  • 11
0 votes
1 answer
50 views

Add and subtract 3 month from a given date time [duplicate]

I have this start date : 2023-09-03T00:00:00+05:30 and end date : 2023-09-10T00:00:00+05:30 I want to subtract 90 days from start date and add 90 days from end date and then convert it to UTC format ...
user3653474's user avatar
  • 3,503
-1 votes
1 answer
57 views

calculate the difference between start_time and current_time as well as end_time and current_time

Suppose,I have created a game and start time is "06/09/23 5:15:23 PM" and end time is "06/09/23 10:20:00 PM" . When user login before time like user login at "06/09/23 4:05:00 ...
vjtechno's user avatar
  • 460
0 votes
1 answer
69 views

Moment js: get string with hours

I am trying to get a string from a moment with hours let hours = 5; console.log(moment().from(moment().subtract(hours, 'hours'), true)); // "5 hours" ОК hours = 24; console.log(moment().from(...
Andrew's user avatar
  • 45
0 votes
1 answer
142 views

Get error when test with jest. Error is Converting circular structure to JSON in moment.js line

I am using angular and jest. My error happens when i add moment.js in code. my import in my component import * as moment from "moment"; Error line const date = moment(new Date(2023, 1, 1))....
Aden Kurmanov's user avatar
1 vote
0 answers
69 views

Showing: TypeError: moment is not a function when we use daterangpicker in Vue JS component

Here is my component code. <template> <input type="text" class="form-control custom-daterangepicker"> </template> <script setup> import moment from "...
abhishekvbajaj's user avatar
0 votes
1 answer
70 views

Uncaught Error: Could not find module `moment` imported from `ui/routes/application`

I'm trying to upgrade moment from 2.18.0 to 2.29.4 along with ember. I have upgraded ember to 4.12.2 but when I run the application, I'm getting Uncaught Error: Could not find module moment imported ...
deva's user avatar
  • 15
0 votes
1 answer
51 views

How to format moment date without considering user's timezone?

Scenario: A user selects a date from +01:00 timezone as 2023-08-26. But when another user from +09:00 timezone view the date it displays as 2023-08-27. I have a date pipe to format dates into M/D/YYYY ...
vinoo jayakody's user avatar
0 votes
2 answers
71 views

javascript filter array gives empty result

I have to iterate on multiple dates intervals: -for example: 09/06/2023 - 15/06/2023 28/05/2023 - 02/06/2023 17/06/2023 - 18/06/2023 29/06/203 - 04/07/2023 ...etc I need to obtain day numbers for ...
GigiF's user avatar
  • 81
0 votes
2 answers
153 views

How to show relative time in react.js project

I'm building social media app using next.js. I want to display relative time in my project. Expected output : just now 2 minutes ago 1 hour ago 2 days I want to retrieve time from MongoDB document ...
Unnikrishnan KJ's user avatar
0 votes
1 answer
73 views

HTML date picker doesn't allow to select Years and months on Safari

In Google date picker allow me to select a year and month without navigating using month to month. But in Safari it doesn't allow me to select a year and month directly. Have to navigate month to ...
Lakshan's user avatar
  • 29
0 votes
1 answer
102 views

Date object with time 24 hour format and start of date 00:00:000

I have a situation where the date field in the database is in local time of different regions. So I need to do some aggregation and I only need to have start and end of a given date. I want the format ...
Dan Hunex's user avatar
  • 5,211
1 vote
0 answers
145 views

Angular 16 - 3rd party script not loading in time?

We've been using moment.js in our app for years at this point, we add it via the scripts property in our angular.json file. Note the definition for the scripts property: An object containing ...
JWrightII's user avatar
  • 942
0 votes
1 answer
62 views

In full calendar JS, I'm want to display the event end date along with event title but, event end date is being displayed in milliseconds (i think)

I have the ajax code below for the calendar: $.ajax({ url: 'display_event.php', dataType: 'json', success: function (response) { var result=response.data; $.each(result, ...
Tashi Tobgyel's user avatar
0 votes
0 answers
42 views

Moment.js: Localized shorthand for placeholder parts, such as "D", "M", "Y"

In the current version of moment.js, I can localize the general format of a date by, for example, using the following code moment.localeData(this.$i18n.locale).longDateFormat('L') It will return for &...
Jakub Albert Ferenc's user avatar
1 vote
0 answers
29 views

How to solve Moment InjectionToken issue?

I am trying to make an UI project to show a work week (Monday - Friday) view calender. The user can book appointments for any time for any date in the work week. Example - I am trying to make the ...
Avishek's user avatar
  • 542
0 votes
0 answers
91 views

How to update the old jquery libraries used in ASP.NET MVC?

In my ASP.NET MVC project running on .NET 4.7.2, I have used kendo ui, jquery.min.js, jquery.signaturepad.js, moment.js, pdf.js, pdf.worker.js, promise.min.js, jquery.signalR-2.4.1.js. I am using ...
Manoj Agrawal's user avatar
0 votes
2 answers
71 views

DateRangePicker Calendar rendering wrong

I'm using daterangepicker to select a range of dates. While everything works fine, the calendar ui which renders to choose dates does not display the dates in the right order. Here is an image for ...
AJ__'s user avatar
  • 1
1 vote
1 answer
48 views

Finding the nearest free time slot from now if free slots in some working days are given

I have a function that takes an array of objects, where each object contains a 'day' key (representing the day of the week) and an 'freeSlots' key (representing an array of available time slots as ...
Aimal Khan's user avatar
2 votes
0 answers
44 views

How to replicate the frowNow function in moment.js in native js Date?

Trying to replicate the fromNow function in moment.js with native JS Date object but getting a date that is one day behind. I'm passing the value as unix it gives the right output when i use moment ...
Dennys Joseph's user avatar

1
2 3 4 5
163