• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details
Home / Time & Date / Check if a date is between two other dates

Check if a date is between two other dates

Check if a date is between two other dates

Use the greater than (>) and less than (<) operators to check if date is between dateStart and dateEnd.

const isBetweenDates = (dateStart, dateEnd, date) =>
  date > dateStart && date < dateEnd;

// Examples
isBetweenDates(
  new Date(2010, 11, 20),
  new Date(2010, 11, 30),
  new Date(2010, 11, 19)
); // false

isBetweenDates(
  new Date(2010, 11, 20),
  new Date(2010, 11, 30),
  new Date(2010, 11, 25)
); // true

Source

https://www.30secondsofcode.org/js/s/is-between-dates

Time & Date

Related Snippets:

  • Calculate the difference (in hours) between two dates
  • Get a formatted list of months
  • Unix timestamp from date
  • Event Calendar Code Generator

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2025 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers