Categories
CMS Joomla Mastering Development

How to compare current date to article created date?

I need a code to compare if current date and time is greater than article created time of joomla.
I have this example code:

  function CompareDate() {  
   //            new Date(Year, Month, Date, Hr, Min, Sec);  
   var dateOne = new Date(2020, 03, 20, 11, 00, 00);  
   var dateTwo = new Date(2020, 03, 20, 12, 00, 00);  

   if (dateOne > dateTwo) {  
        alert("Date One is greater than Date Two.");  
    }else {  
        alert("Date Two is greater than Date One.");  
    }  
}  
CompareDate();  

Where I need:
‘dateOne’ to be the current date and time and
‘dateTwo’ to be the article createad date and time

Any help with this?

Leave a Reply

Your email address will not be published. Required fields are marked *