Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
42 views

moment doing wrong calculations for day of the year

I am trying to find the day of the year using unix epoch and it returns 365 instead of the correct value. here is the code snippet const momentY = moment(new Date(startDate)) startDays = momentY....
Moblize IT's user avatar
  • 1,304
0 votes
1 answer
56 views

Change date with button (prev-next) from calendar using only moment library

I want the date to change month when the prev and next buttons are clicked. The following code is working, as you can see. It just seems like dirty code to me. document.getElementById('nextdate')....
ghost_of_the_code's user avatar
0 votes
3 answers
121 views

Why does moment.startOf go back 1 hour?

Edit: My local timezone is UTC+1 I have this date string: 2024-07-01T00:00:00.000Z. This date string has a 'Z' at the end which denotes that it is in UTC (If I understand correctly). When I run ...
kenwilde's user avatar
  • 123
0 votes
0 answers
59 views

JS script to validate date in between 2 dates gives error if end date is different month

I'm trying to develop a script for Flokzu (A BPMN software that uses js scripts to define form field validations) and i'm asked to validate vacation days request fields. E.g. start date is after today ...
Vaney Rio's user avatar
0 votes
0 answers
40 views

How can I delete time from date in moment().calendar()?

I am trying to get Today and Tomorrow titles from date using Moment Calendar. In case moment(date).calendar() I get Tomorrow at 12:00 AM. But I need without time. Just Tomorrow In case moment(date)....
Oleksandr's user avatar
1 vote
0 answers
112 views

How to get list to time zone abbreviations in JavaScript?

I'm writing a date-related logic where the timezone name is important. The user enters the time whatever they want and the timestamp then gets converted to the timezone mentioned internally in a ...
avishekdr's user avatar
  • 1,086
4 votes
2 answers
9k views

Angular patchValue vs setValue and dates

Is there any significant difference between using patchValue or setValue to set the value on a form ? Also is there any difference or best practice regarding using moment or date obj ? if(...
Giorgos Saramantis's user avatar
0 votes
0 answers
49 views

Reconstructing a date from year, isoWeek and day with MomentJS

I am working on an application which saves events to a NoSQL database which is separated into collections using the year, week and day of the event. The events are saved in such a way that all events ...
Tech's user avatar
  • 155
-1 votes
1 answer
45 views

Server side dates formatting

I have a nodejs server that I am sending messages from him. I want to format dates by the receiver localization data. If he is from US so the hour will be 2:00 pm and if he is from UK the hour will be ...
Dvir Avrahami's user avatar
0 votes
0 answers
35 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
0 answers
79 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,515
0 votes
1 answer
159 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
-1 votes
1 answer
78 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
  • 484
2 votes
0 answers
76 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 vote
0 answers
120 views

Does Moment Timezone automatically adjust the time based on DST when formatting a time string?

I want to convert the UTC ISO 8601 date string into the user's local date time based on the user's Time Zone. I'm using moment-timezone to accomplish this task, and here is the code snippet: const ...
programmers_view's user avatar
0 votes
0 answers
296 views

How to get current global date time(not mobile date time) in react native?

I want the current date time. currently, I am using moment but it takes device date time. How can I achieve this in react native?
Divyata Chauhan's user avatar
0 votes
1 answer
30 views

How to write next to date in JS?

I have a calendar in which I want an if case that allows me to get rid of the enddate if a single date booking is made: if (Startdate next to Enddate); { Enddate = False } How would I be able to ...
polish_prince's user avatar
0 votes
1 answer
48 views

Looping over users and their loggedin dates and merging data sets

I am trying to build some dashboard components - and I want to loop over the data to get a total login count per day over all the users. code would look something like this - but need to set flags to ...
The Old County's user avatar
3 votes
2 answers
125 views

Generating random dates between start date and end date in utc format using javascript

How can i generate random dates between two dates in utc format using javascript? example: start date is 23-01-25 02:07:04 and end date is 23-02-25 02:07:04 I want a list of random dates between start ...
Sabita Nadar's user avatar
0 votes
1 answer
58 views

How to check if the current time lies between the two times that open and close in utc timing?

I am trying to check if the current time lies between the two timings open and close. based on that,I have return the color,tried code but getting wrong result,input timings are in 24 hours clock. ...
Manish Kumar's user avatar
1 vote
3 answers
628 views

MomentJS isSameOrAfter

I'm currently trying to switch a status to active if the end date of a plan is the same as or after today's date. This is what I currently have: const today = moment(); const ...
Jeremy Chee's user avatar
0 votes
0 answers
136 views

How to convert utc time to 24 Hrs format in react native

I am new to react native ,I am trying to convert the given time "14:58" to utc in 24 hrs format. I am using the code like this let currentDate = new Date(); startDate = new Date(...
Manish Kumar's user avatar
0 votes
1 answer
45 views

Convert formatted date to html date format

I'm trying to convert this date format 2019-11-27T00:00:00 to the html date format of 2019-11-27. Is there an existing function on moment which does this?
Jeremy Chee's user avatar
0 votes
1 answer
221 views

How to transform YYYYDDD to DD-MM-YYYY [closed]

I have a date which is given in YYYYDDD format, where YYYY is the year and DDD the days through the year (001-365). Does the library from moment.js or any other library has a conversor for this kind ...
Zander's user avatar
  • 1,076
0 votes
2 answers
1k views

How to convert today date local date to UTC with time 00:00:00 and 23:59:59 in javascript or Moment.js?

I am sending Start Date and End Date as parameters after converting those dates into UTC. I am facing difficulty due to time span. I have used the moment.js to convert into UTC format. var today = new ...
Ranjan Singh's user avatar
0 votes
2 answers
652 views

Compare dates of an array using moment or dayjs library in javascript

I need to compare the date values of an array. I will always get two dates values in array. If date range is not in between 5 years need to display error message. filterAry = [ {type: 'date', name: '...
user1881845's user avatar
0 votes
3 answers
703 views

How to get this week's data only from array of objects in Javascript? [duplicate]

I'm working on an algorithm that should return this week's data from an array of objects (includes data for the whole current month), data looks like this: [ { date: 02/01/2023, // date is in ms ...
nika's user avatar
  • 125
0 votes
1 answer
492 views

How to correctly create a date condition using moment js

There is a table with data and dates. Please help me to make a correct condition so that when it is triggered, the date will be coloured in different colours. The table has a Deadline column. I need ...
IndieDev's user avatar
0 votes
1 answer
44 views

MomentJS - shifts the date by a day after format operation

To work with one component, I need a unix date, to work with another - a text display of days, months and years. Also, each of them can be changed and the second one must synchronize its date with the ...
Gelloiss's user avatar
  • 184
0 votes
1 answer
63 views

Timestamp: Calculate full date and minutes difference in moment.js

I'm calculating the time in minutes using timestamp and moment. So far I can format timestamp with moment but the calculation is a NaN. This is my code: function (val) { var a = moment.unix(val[0])....
Rolanda's user avatar
  • 348
0 votes
1 answer
373 views

How can I get date of the last given "day" in Typescript?

I would like to get the date (YYYY-MM-DD in format) for the last "Wednesday" or "Saturday" or any day that user passes. It could either be from this week or last week, but the ...
AnOldSoul's user avatar
  • 4,197
2 votes
2 answers
744 views

Moment and date-fns formatting date incorrect

I have been trying to format a zulu format date to normal date i.e. MM/dd/yyyy, so far I have tried date-fns and moment. The date I have is 2022-11-03T19:48:24Z I am expecting it to be formatted as 11/...
Yash's user avatar
  • 786
1 vote
1 answer
139 views

How many iterations of a complex duration of time exists between a start date and end date?

For example, I'm using the moment.js library. You can specify a duration as follows : {years:1,months:1,weeks:1,days:1,hours:1,minutes:1,seconds:1}. This duration of time is subjective based on the ...
Joseph Astrahan's user avatar
1 vote
1 answer
159 views

Moment utc timezone removal

I have a moment date that's displayed in the console as Moment<2022-11-04T20:45:35+02:00> I want to regardless of the browser, remove this utc adjustment and always have the date as Moment<...
Macky_01's user avatar
0 votes
1 answer
73 views

Is there a way to modify date iso string such that in JS, new Date(isoString) does not return date in daylight saving time

After setting system clock to EST, on converting iso string to date object using Date constructor we noticed that dates between March and November return offset time -4 hrs i.e. daylight saving time ...
Dhiren Punjabi's user avatar
3 votes
3 answers
343 views

How to increase day number with every map loop (Moment.js)?

I'm making a simple week calendar in React where I need to display columns with hours. A calendar will be generated onClick and based on the actual week number will show the whole week mon-sun. I'm ...
MarcinB's user avatar
  • 39
0 votes
1 answer
164 views

date range validation by month in nodejs moment.js

I am trying to validate or check the date range by passing month and year, If date range come under the given month range between, then it would be valid else error. month = "04, 06, 2022"; /...
Danjay Rathor's user avatar
0 votes
1 answer
342 views

Formatting date with moment js

I am using moment js in react, how can I format date like this [2022m12d23] and [2022m12] ? Thanks
Aya Abdessalem's user avatar
1 vote
2 answers
108 views

Calculate calendar week for each week between two dates

Using a startDate and an endDate, i need to get an array of calendar weeks for each week between the dates. Example: startDate: 12/02/22 endDate: 01/28/23 Given these two dates, i need to get an array ...
femorom424's user avatar
1 vote
2 answers
661 views

How get UTC of start of day for specific timezone?

I have to convert 2022-11-29 to '2022-11-29T04:00:00.000Z' it is offset for Santo Domingo Timezone. But the first problem StartFromUtc is already '2022-11-29T02:00:00+02:00' but I expected '2022-11-...
Mediator's user avatar
  • 15.3k
1 vote
1 answer
230 views

Compare dates in different years knex javascript

I am using knex to get a list of clients with their birth dates on mysql. I want to get only clients that are having birthday on the next month. I think the best way is to compare dates ignoring the ...
carolcal's user avatar
0 votes
4 answers
778 views

How to enable/validate date input only from current date to 50 years before in Moment.js?

I am using moment.js. I want to restrict the user son that he can only select a date which is from current date to 50 years before. In short, i just want that user's date of birth cannot be more than ...
Anshul's user avatar
  • 71
0 votes
0 answers
44 views

How can we get format from the date?

We have moment to format a date into give format, like below moment(new Date()).format("YYYY-MM-DD") // 2022-11-09 But how can we get the format from a date, for eg: let inputDate = '02/01/...
Praveen RL's user avatar
0 votes
1 answer
449 views

moment(to).toDate() returns a day earlier in momentjs

I am trying to match a specific date that a user can select from a date picker with my mongoDB, but when i put moment(to).toDate() a returns for me the date -1 days. for instance moment(10-25-2021)....
user avatar
-1 votes
1 answer
346 views

Moment Format Returns different values in backend / frontend code

Does moment(date).format('LL') return different values based on locale / timezone? On my backend I'm getting: October 24, 2022 and on my frontend I'm getting 24 October 2022. What can I do to ensure ...
Alk's user avatar
  • 5,553
0 votes
1 answer
808 views

Angular: date format YYYY-MM-DDth:mm:ss.sssz+ZZ:ZZ displaying with moment().format()?

I would like to display an array of dates having the following format: YYYY-MM-DDth:mm:ss.sssz+ZZ:ZZ. For example: 2022-10-20T14:25:00.016Z+03:00 as DD.MM.YYYY and hh:mm seperatly. For this I'm using ...
Patrice's user avatar
  • 19
0 votes
1 answer
154 views

Angular: Using moment.format method in HTML [duplicate]

is there a way to use the moment.format method in HTML? I'm currently using the toLocaleDateString method to display an array of dates: <ng-template let-event> <...
Patrice's user avatar
  • 19
0 votes
2 answers
2k views

How to add minutes and hours to a string in MomentJs

If I have a string like '15:30', how can I transform it into '17:10'? I tried to do the following: time = '15:30' moment(time) .add(40, 'minutes') .add(2, 'hours') .format('HH:mm') But it didn'...
chupapee's user avatar
  • 525
1 vote
1 answer
174 views

Set hour for initial timezone of the date in javascript

If I receive the following date string on the server which has a timezone of +03:00 2022-10-24T00:00:00+05:00 I want to set the hour to something fixed, 8 A.M. let's say, so the result would be 2022-...
Flo's user avatar
  • 41
0 votes
2 answers
350 views

Generate week start date, week end date, month week no by using the given date range in javascript

I have given a date range as input ie a start date and an end date, I need to construct an array that contains the week No and the week start date, and the week end date as output. Input: startDate = &...
Subha's user avatar
  • 59

1
2 3 4 5
24