Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

javascript compare two date time code example

Example 1: compare dates in javascript

var date1 = new Date('December 25, 2017 01:30:00');
var date2 = new Date('June 18, 2016 02:30:00');

//best to use .getTime() to compare dates
if(date1.getTime() === date2.getTime()){
    //same date
}

if(date1.getTime() > date2.getTime()){
    //date 1 is newer
}

Example 2: compare date and time in js

var isLarger = new Date("2-11-2012 13:40:00") > new Date("01-11-2012 10:40:00");

Tags:

Javascript Example

Related

what does PASSWORD_DEFAULT do code example how to make JSON.strigify pretty print code example make circular image flutter code example laravel migration default value and after code example what is devServer in webpack code example COMO RENOMEAR UMA BRANCH code example js capitalize each string in array code example how to create an shortcut in terminal linux? code example what is vue.h code example intersect in sql server code example pickle read file python code example python write list of strings to file code example

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy