小编SPn*_*PnL的帖子

Comparing two dates in jquery script

I'm trying to compare two same dates in the browser console and getting the result as false. I don't understand how is it comparing as both the dates are the same?

$(function()
{
  var d1 = new Date("01-12-2001");
  var d2 = new Date("01-12-2001");
  
  console.log(d1 == d2);
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

but here if try to compare with GT and LT then its working.

javascript jquery date date-comparison

-2
推荐指数
1
解决办法
62
查看次数

标签 统计

date ×1

date-comparison ×1

javascript ×1

jquery ×1