Questions tagged [dayjs]

Day.js is an immutable date library for JavaScript

Day.js is a minimalist JavaScript library that parses, validates, manipulates, and displays dates and times for modern browsers with a largely Moment.js-compatible API.

https://github.com/iamkun/dayjs

Stack Snippet Starter Pack

(from day.js.org)

HTML

<script src="https://unpkg.com/dayjs@1.8.21/dayjs.min.js"></script>

JavaScript

console.log(dayjs().format())

Useful links

281 questions
5
votes
2 answers

dayjs - not a function

I'm passing two dayjs date to Vars.date global variables. var dayjs = require("dayjs") for import Vars.date1 = dayjs(whateverdate1("add", 2)).format('MMM D, YYYY') Vars.date2 = dayjs(whateverdate2("add", 2)).format('MMM D, YYYY') const date1 =…
brobee
  • 231
  • 1
  • 5
  • 25
5
votes
1 answer

How to detect first day of a month with Day.js

I am building a calendar component in React without using any library but Day.js. I need to detect the first weekday of the month in order to leave a gap as shown in the picture. Otherwise the first day of every month has to be Sunday. How can I…
aydgn
  • 167
  • 1
  • 8
5
votes
3 answers

Mock DayJs default function along with its chained methods

I'm trying to mock dayjs() default function with specific date & time and also wants to mock its nested methods i.e .utc() & .add() This is what I've tried so far: abc.ts: getEarliestDate() { const { minHour, maxHour } =…
Mohammed Amir Ansari
  • 2,311
  • 2
  • 12
  • 26
4
votes
2 answers

TypeError: dayjs.utc is not a function

I am getting this error dayjs.utc is not a function Here is my code const dayjs = require('dayjs') console.log('utc time',dayjs.utc())
4
votes
2 answers

yup date validation - Start Date must not be same as end date

I am currently stuck on how to do validation with yup for same date. Currently I am able to validate if endDate is not before startDate using : schema = yup.object().shape({ startDate: yup.date().min(new Date(),'Please choose future date'), …
FadhilRadh
  • 103
  • 1
  • 1
  • 8
4
votes
2 answers

dayjs().startOf('day') shifts two hours back

I'd like to sort out a dayjs problem I am experiencing. Right now, I'm out of clues and/or guesses of what can happen, apart from the bad timezone setting. But again, how could timezone play a role here, if I didn't even modify it anywhere in my…
Rusurano
  • 444
  • 5
  • 12
4
votes
1 answer

Handle separator with Material dayjs date adapter

In my Angular application I need to swap from momentjs to dayjs. Because I am using material I have to replace moment-date-adapter with a dayjs-date-adapter, so I write my own date adapter but I can't understand how momentjs can parse a date like…
ACeleghin
  • 111
  • 7
3
votes
1 answer

Chartjs adapter for Dayjs CDN: Uncaught ReferenceError: process is not defined

I'm using the CDN for the adapter for Chartjs to utilize Dayjs (chartjs-adapter-dayjs-4) and I'm getting the error Uncaught ReferenceError: process is not defined I need to be able to use the CDN link for the Javascript that I'm writing, but I can't…
3
votes
2 answers

How to combine date and time using dayjs?

If following data represent date and time respectively: date: 2023-04-04 time: 13:02:00.963+00:00 How do I combine above date and time using dayjs, so it looks as below format: 2023-04-04T13:02:00.963Z Is there any built-in method to do this? and…
Mir Stephen
  • 1,758
  • 4
  • 23
  • 54
3
votes
4 answers

ant.design v5.2.0 - date.locale is not a function

I have the following problem: I am using ant.design in version 5.2.0. When I use the component as follows, I always get the attached error message when I pass a date to for the Form.Item in dayjs format: enter image description here If I don't…
3
votes
1 answer

Datepicker compatible with dayjs

I'm trying to move from momentjs to dayjs, however my React project is using rc-calendar to display calendar ranges and datepickers. Rc-calendar uses momentjs date formats and does not work with dayjs. I'm having trouble finding a daterange library…
Robert
  • 43
  • 4
3
votes
2 answers

TypeError: dayjs(...).tz is not a function

I am getting this error. TypeError: dayjs(...).tz is not a function My code is const dayjs = require('dayjs'); const dayjsAmerica = dayjs("2014-06-01 12:00").tz("America/New_York");
3
votes
1 answer

What is the typescript type of dayjs object

I am using the ant-design date picker component with dayjs as the date library. The component is controlled with the initial value being null and the value changes to dayjs object based on some operations in the code. The below code is a part of the…
user20002028
3
votes
0 answers

How to get timezone name list using dayJs

I was recently using momentjs but just switched to dayjs. However, I need to get a list of timezones. With momentjs it was pretty simple : moment.tz().names() , but with dayjs I can't figure out how to do it. I don't want to get 500+ timezone,…
John
  • 179
  • 1
  • 4
  • 13
3
votes
2 answers

Get Minutes and Hours diff with dayjs

I am trying to get a meeting duration to subtract the meeting end time and with meeting start time. So far with dayjs "hours" parameter, I can get the hours difference. But I also want to get minutes duration. For example, if the meeting is less…
Toufiqur Rahman
  • 202
  • 3
  • 17
1
2
3
18 19