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
0
votes
1 answer

Cypress - replaceing moment() with dayjs

I'm having problems with the locale when going from the deprecated Moment to DayJS in Cypress. The original Moment() usage: public moment(): Moment { const moment = Cypress.moment(); moment.locale("nb-NO"); return moment; } const…
user9347168
0
votes
2 answers

Dayjs with Nuxt/Vue: Button to change timezone

I've been tinkering around with a booking system using dayjs. Currently it imports objects with a DateTime in the 'Australia/Melbourne' timezone, and I'm looking to make a dropdown that changes the timezone that it's currently being displayed in.…
Jack Sumner
  • 43
  • 1
  • 5
0
votes
1 answer

Convert from UTC C# SQL

Using a combination of server-side C#, SQL database, and the dayjs client-side library dayjs I am unable to convert the date stored as UTC in the database UTC to local time. My theory is to store all date-times in the database as UTC. Use the client…
Brett
  • 786
  • 1
  • 8
  • 10
0
votes
3 answers

why does all other values update while i used useEffect() on just 'time'?

The gap variable should just give a difference once, but it gives a diff every second. I am not even updating its state. Even if i use settime in useEffect still the other variable that are changing in background are still effecting the page and are…
0
votes
0 answers

How to use day.js module to set a timezone and convert a set time from EST to UTC?

I am reading in a variable string, DateTime = "2019-11-21T08:29:56EST", from another file. The format of this string with the 'EST' is a outlier for my files. I want to identify this time as EST, remove the characters of "EST" from the string or…
A. H.
  • 3
  • 5
0
votes
1 answer

check if a date is between two dates in different years

I'm gonna use MomentJs or Dayjs to see if for instance Apr/03 is between Nov/01 and May/01. When we try isBetween it doesn't work as in a year Nov/01 is not before Apr/03 but if you look at it as a two-year scop it should return true for…
0
votes
1 answer

Day.js - Get array of remaining months in year

I want to get an array of the index of remaining months (0-index), not including current month, in a countdown, this year (or any date for the sake of it). I'm using lodash and dayjs, but I feel my code is a bit hard to understand. Is there a more…
Doge
  • 315
  • 1
  • 8
  • 26
0
votes
0 answers

Correct formatting of date with dayJS

I am getting an 'Invalid Date' error when passing my date in the format of 1990-12-29Z into dayJS I've tried using the various plugins available with no luck, how can I get my date to display as a valid…
0
votes
1 answer

How to get the first day of week with year?

// result is: 2014/12/29 moment('2016/01/01').isoWeek(1).startOf('isoWeek').format("YYYY/MM/DD") // result is: 2016/01/04 moment().year(2016).isoWeek(1).startOf('isoWeek').format("YYYY/MM/DD") The second is right, but I don't know why the first go…
Coy
  • 1
0
votes
0 answers

How to disable public holidays from datepicker with dayjs

I have a datepicker where I use @material-ui/picker. I want to disable all the public/bank holidays from the datepicker. I'm using day with days.js. But im not quite sure on how to proceed. I have my datepicker: import nl from…
Alison
  • 199
  • 1
  • 2
  • 11
0
votes
1 answer

Relative time in weeks is not supported in day.js

I just migrated from moment.js to day.js. The migration was very smooth but day.js is not providing relative time in weeks. What I was doing in moment.js // Round relative time evaluation down moment.relativeTimeRounding(Math.floor); …
Ubaid ur Rehman
  • 128
  • 1
  • 7
0
votes
1 answer

How to check between two dates

I have two different array: accomodation: [ { id: 1, name: "Senator Hotel Fnideq", address: "Route de Ceuta, 93100 Fnidek, Morocco", checkin: "September 1", fullCheckinDate: "2021-09-01", checkout: "September 3", …
Peoray
  • 1,705
  • 2
  • 12
  • 21
0
votes
0 answers

Convert Rails TimeZone for use in Javascript Day.js

I'm using Rails TimeZone Input: <%= time_zone_select( "user", "time_zone", nil, default: "Pacific Time (US & Canada)" ) %> but now I'm trying to pass that value (stored in javascript in a variable called user_timezone_string) to a javascript…
mcfloor
  • 41
  • 3
0
votes
2 answers

Why isBefore method doesn't work as expected in dayjs?

I am trying to create a calendar with dayjs but doesn't work though the same code is working in momentjs. My code is: import dayjs from 'dayjs'; const calendar = []; const today = dayjs(); const startDay =…
jifakir
  • 76
  • 1
  • 9
0
votes
1 answer

DayJS formatting with duration plugin returns undefined when passing day, hour and minute

Using momentjs, it works perfectly fine - returning 13m: moment.duration(sg.time_played, 'seconds').format('d[d] h[h] m[m]') And with DayJS: dayjs.duration(sg.time_played, 'seconds').format('d[d] h[h] m[m]') It would return the following string:…
user13050631