Skip to content

Tag: date

Writing a JavaScript program to calculate a leap year

I am writing a JavaScript program that takes in a date typed by the user and determines what day of the week the given date falls on. I am able to get the program to take in the date. I have used debug statements to print the values of the day, the month, the year, and the century to make

JavaScript for getting the previous Monday

I would like for the previous Monday to appear in the field where a user enters today’s date. E.g.: If today’s date is entered 29-Jan-16 then the code would make the previous Monday’s date to appear instead (which would be 25-Jan-16). I have seen some code online: However, this is not quite …

Compare date with todays date 10 years ago

I want to check if the given date is higher than 10 years ago from today (so the person would have less than 10 years). I have searched many info with no possitive result. EDIT: When I alert “objetoFechaNacimiento”, if the user entered “22/1/2015”, it alerts “Sat Oct 01 2016 00:0…

Get hours difference between two dates in Moment Js

I’m able to get the difference between two dates using MomentJs as follows: However, I also want to display the hour when applicable (only when >= 60 minutes have passed). However, when I try to retrieve the duration hours using the following: it is returning the current hour and not the number of ho…