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 dig…

Dates stuck in month loops

The dates go to one month either side and then get stuck in loops. Starting in June, it will go fine to end of July, or start of May, but then loop back to the end/start of those months instead of going further. globalDate is a React state defined const [globalDate, setGlobalDate] = useState(new Date()); Code…

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