• 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 the given date is a weekend

Check if the given date is a weekend

Check if the given date is a weekend

Use Date.prototype.getDay() to check weekend by using a modulo operator (%). Omit the argument, d, to use the current date as default.

const isWeekend = (d = new Date()) => d.getDay() % 6 === 0;

// Example
isWeekend(); // 2018-10-19 (if current date is 2018-10-18)

Source

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

Time & Date

Related Snippets:

  • Simple Calendar
  • Check if a date is between two other dates
  • Get the date for a specific day of the week
  • Unix timestamp from date

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