date-fns Questions

2

Solved

I'm trying to compare two dates in UTC format with date-fns, but I'm not getting it. The two values ​​look the same, but the isEquals() function returns false for comparison. The purpose of the co...
Gangboard asked 10/6, 2020 at 19:39

3

I want to be able to find out the nearest Day of the week in the past based on the current date with date-fns. Say I need to find nearest Friday, Wednesday, Thursday etc in the past based on the cu...
Lamellar asked 11/1, 2019 at 7:54

4

I try to replace momentjs with date-fns but I am struggling with a very simple thing: I need to calculate startOfDay, end of day and addDays for the dates that I have got in timestamps and accordin...
Nutmeg asked 3/6, 2021 at 10:15

7

Solved

Given int value 1807, format to 30:07 using date-fns? Yes, I know this can be achieved with vanilla js, but is this possible using date-fns?
Efface asked 13/2, 2018 at 21:43

2

Solved

I have an app that receives a list of supported locales from the backend as a following response: {locales: [{code: 'enUS'}, {code: 'deDE'}, {code: 'arAR'}]} I want to use date-fns library for han...
Zamboanga asked 16/3, 2021 at 15:10

11

Solved

Problem It looks like when I use the format() function, it automatically convert the original UTC time into my timezone (UTC+8). I have been digging through their docs for hours and couldn't seem ...
Kinzer asked 25/10, 2019 at 15:8

4

Solved

How can I set the placeholder text of the MUI DatePicker. The text that is displayed when deleting the text in the input field. I want to set the text to "tt.mm.jjjj" and I always the fol...
Asclepiadaceous asked 11/10, 2021 at 11:29

36

How to get the difference between two dates in years, months, and days in JavaScript, like: 10th of April 2010 was 3 years, x month and y days ago? There are lots of solutions, but they only offer ...
Corvin asked 18/7, 2013 at 20:4

2

So basicly I am trying to use addBusinessDays(new Date(), 3) which sets a startdate without taking weekends into account. However I need to make use of a list of dates ( holidays ) into this aswell...
Northington asked 18/12, 2019 at 12:13

4

Solved

I'm using date-fns I would like to convert new Date(2020,1,10) to 'Thursday'. I'm trying to use dateFns.format(new Date(2020,1,10),'dddd') but it returns 0001? Thanks in advance
Collimate asked 1/10, 2020 at 15:44

3

I'm trying to display a count-down timer using date-fns library and doing things the below way, unable to find the solution in react. Expected output: 60 days : 8 hours : 9 minutes : 5 seconds rem...
Glitter asked 25/9, 2019 at 3:28

3

Solved

I just want to validate if the string that i received is a valid date using date-fns. I gonna receive a date like this '29/10/1989', BR date. I want to transform it into 29-10-1989 and check if its...
Crock asked 5/2, 2021 at 17:49

3

My old code use momentjs, something like this : moment(createdAt, 'YYYY-MM-DD HH:mm:ss').toISOString() What is the equivalent method on date-fns that will reproduce same result ?
Mask asked 27/8, 2018 at 6:46

2

Solved

I'm using react-datepicker along with date-fns to display a date picker with Hungarian locale in my Web app, but I couldn't find a way for it to display the dates of the week starting with Monday i...
Sawfish asked 2/7, 2021 at 22:12

2

const dt = new Date('2017-12-12'); console.log(format(dt, 'YYYY-MM-DD')); The above code logs 2017-12-11 in the US, but 2017-12-12 in India. I followed this github thread here and tried out thin...
Dunagan asked 9/1, 2018 at 16:38

2

I'm using date-fns in a React project. const sampleText = 'Tue Aug 03 2021 18:49:11 GMT+0800'; const sampleDate = new Date(sampleText); format(sampleDate, 'hh:mm') This returns '06:49'. How can I ...
Goldstone asked 7/10, 2021 at 2:52

5

Solved

I am trying to parse date using date-fns library but getting one day previous as result. How can I avoid this and get the right result? start = '2021-08-16' const parseStart = parse(start, 'yyyy-MM...
Bunin asked 16/8, 2021 at 18:59

2

Solved

It's pretty straightforward to set a locale in a per-function call basis: import { formatRelative, subDays } from 'date-fns' import { ptBR } from 'date-fns/locale' formatRelative(subDays(new Date(...
Brasil asked 16/6, 2021 at 12:23

4

Solved

The displayed date in Material UI Pickers is 1 day behind the selected date: I selected 25th, the value in formik is 25th but the value displayed on the form is 24th. "@date-io/date-fns": "^1.3...
Ulrick asked 24/2, 2020 at 18:39

2

Using 2.0.0-beta.4 of date-fns I'm stuggling to figure out the format string for parsing and ISO date. My date string is as follows: 2019-08-31T14:36:28.511Z And the parsing code is as follows...
Dedal asked 1/9, 2019 at 12:27

3

Solved

How can I get the name of the month in nominative format? import { format } from 'date-fns'; import { ru } from 'date-fns/locale'; format(new Date(), 'MMMM', { locale: ru }); // июня How can I g...
Deathtrap asked 4/7, 2020 at 14:24

2

Solved

I have the following configuration on the app-module.ts import { ReactiveFormsModule } from '@angular/forms'; import { DateFnsAdapter, MatDateFnsModule } from '@angular/material-date-fns-adapter'; ...

3

Solved

I'm using React Material UI and I get this error : Module not found: Can't resolve '@date-io/date-fns'. Here are the dependencies that I have in my package.json file : "dependencies": { "@date-i...
Craquelure asked 15/5, 2020 at 15:23

2

Solved

I want to get a ISO-8601 format of last hour:minute:secounds from the current day using date-fns lib: I'm using: endOfDay(new Date()); Fri Sep 14 2018 23:59:59 GMT-0300 So add toISOString() to g...
Breault asked 14/9, 2018 at 14:55

2

Solved

I've been trying to format a date using date-fns but I keep failing. Basically I have it working just fine with momentJS but not with date-fns: Here's my date: "10-13-20" // month, day, a...
Closefisted asked 14/10, 2020 at 22:15

© 2022 - 2024 — McMap. All rights reserved.