Skip to content

Tag: date

Convert a string to date in JavaScript

I have the following string and I want to convert it to Date ‘20220722T141444Z’ In C# I converted it by telerik’s DateParser library. Is there a way to convert it in JavaScript as well? Answer There are many questions on parsing timestamps. In this case, you can just get the parts as two digit pairs then use that to call

Date-fns Unexpected results when adding months

I am using date-fns for the first time in my project. I need to give user the ability to add a month to current date. I’m wondering how is this supposed to work with different length months? I tried different months with 30 and 31 days and I cannot make sense of it. If I add a month to July

Using computer date and adding a day indicator

I have been trying to display the following “on this 4th day of January in the year 2022” using javascript on an HTML page but for some reason it is displaying today as the 2nd and not the 4th and where I want to display ie. 4th March 2022 (today +89 days) it is failing to do so… So the

how to scroll years using pikaday?

I am using pikaday.min.js and pikaday.min.css in my project. The problem is with the years. When I click the year, the options are the chosen year -/+ 10 years, but there is no scroll option when the grey box pops up. For ex. if I want to select year 2002 in the example below, I must select years <2012 in

Javascript SetMonth Issue

I am doing unit tests. On my local node process I get this error On docker node process it works. I believe it is related to the DST, but I don’t understand how… Answer You’re right that DST is coming into play, because you’re using the local time setMonth/getMonth methods, so DST comes into it (adding the month, the Date