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

How to change timezone for the ngx-daterangepicker-material daterangepicker in Angular 9?

As per my requirement , I want to show the Hong Kong timezone even users from other timezone in ngx-daterangepicker-material. But date time picker shows locale time for Indian users . Here it needs to show the time of Hong Kong , not Indian time.
0
votes
1 answer

Dayjs: group data by each day while still keeping the format

I have the following data structure from the API, it comes in as an array of Data, each Data element is intervaled by 1 hour. interface Data { time_bucket: string // ISO8601 string aggregated_value: number // 0 and up } My plan is to format…
grindarius
  • 119
  • 3
  • 7
0
votes
1 answer

Console.log(appointment[0].apps.date) gives a date, but I get 'Cannot read property 'date' of undefined' when I use it in my function

I keep getting Cannot read property 'date' of undefined when I call my getDataPrevDay function, but console.log(appointment[0].apps.date) logs the correct date const admin = ({data}) => { const [appointment, setAppointment] =…
gnrcs
  • 89
  • 3
  • 9
0
votes
0 answers

Creating time ranges from a series of UTC timestamps marking when a users status changes from active to away?

I have a series of json objects that each contain a timestamp of when an event occurred for a specific user. The JSON object presence can be either active or away. I need to find the earliest active time on a specific day and then locate the first…
Blake Bell
  • 376
  • 5
  • 16
0
votes
1 answer

how to add dayjs in ruby on rails application?

I add this https://unpkg.com/dayjs@1.10.4/dayjs.min.js file into javascript/packs and require("packs/dayjs.min.js") I'm not sure, maybe I need to load some plugins? I want to know how can I convert datetime attribute for clients in them timezone on…
Lemon
  • 25
  • 5
0
votes
1 answer

Why is DayJs Causing Site to Freeze and Not Load?

So, I have a site that requires day.js, and I've had some experience on previous sites, and it's worked fine, and loaded fast. But as soon as I try to use it on a new site, it just causes it my site to freeze up. I've tried using defer and async but…
R3FL3CT
  • 551
  • 3
  • 14
0
votes
1 answer

Generating a 24 hour UTC date range for a timezone using dayjs

I'm trying to create a function which returns the start and end time for a given date and given timezone in UTC using dayjs. These are examples of the results I think I…
net.uk.sweet
  • 12,444
  • 2
  • 24
  • 42
0
votes
1 answer

How can I change the time I write a comment like Instagram? in reactnative by using dayjs

I am using react native with dayjs. I want to compare the time when the comment was written with the current time, and then record the compared time on the console.log(expectedtime) by using dayjs Like this example function displayedAt(createdAt) { …
user15322469
  • 841
  • 1
  • 8
  • 31
0
votes
1 answer

How to find the time difference with dayjs in cypress?

I'm trying to find the time taken for an element to load using this code but doesn't work. Expected Result: Total time taken is 90 seconds(or in milliseconds) const start = cy.log(dayjs.format("HH:mm.ss.SSS)); const end =…
Seeker
  • 101
  • 3
  • 15
0
votes
2 answers

Setters in DayJS Library

I am trying to figure out setters in dayjs. To that extent, I tested out the following code: let orwell = dayjs(); orwell.year(1984); console.log(orwell.format("YYYY")); My expectation is that the year 1984 will show up in the console. But that…
Moshe
  • 6,011
  • 16
  • 60
  • 112
0
votes
1 answer

Convert server default time to user's timezone unknown in advance using dayjs?

How do I convert server's default timezone to the user's local time? date(){ const date = dayjs(this.status.date);//returns string with time server, for example 2021-02-26 05:40:29 return date.hour() === 0 && date.minute() === 0 ?…
0
votes
1 answer

dayJS date function to PHP Carbon

I have the following date processing in dayjs which I am trying to replicate in PHP but failing. I expect both to return Monday 27 July 2020. Can someone help? JS - returns Monday 27 July 2020 var firstOfMonth = dayjs('2020-08-01'), …
0
votes
1 answer

KnexJS select all records from current year

I just want to be able to select all records from this current year, like, we're in 2020, select all records which created_at year is greater than 2020. const current_year = dayjs().format('YYYY'); I'm using dayjs to get the current year. How can i…
Kakiz
  • 1,145
  • 1
  • 9
  • 18
0
votes
0 answers

set the starting month as 0 instead of 1 ngb datepicker

I am using Datepicker control https://ng-bootstrap.github.io/#/components/datepicker/overview. I am using CustomDateParserFormatter to parse the date to different format. My issue is I am using dayjs to transform the dates which intern returns the…
threeleggedrabbit
  • 1,722
  • 2
  • 28
  • 60
0
votes
1 answer

React app freezing after iterating over array in component return

I'm working on adding a calendar feature to my React application. I'm using this tutorial to do it. I'm trying to use Day.js instead of Moment, because Moment is in legacy mode, and Day.js was one of the recommendations. It seems that most of the…
cpppatrick
  • 609
  • 3
  • 12
  • 29