Search code examples
javascriptjquerygoogle-chromemozilla

Different behaviour of Javascript between Chrome and Mozilla


[based on this question]

Based on previous question, I find below code is meet my requirement.

if (bannerStartDateTime >= workOrderCampaignStartDateTime 
        && bannerStartDateTime < workorderCampaignEndDateTime 
        && bannerEndDateTime > workOrderCampaignStartDateTime 
        && bannerEndDateTime <= workorderCampaignEndDateTime) { }
else {
    alert ("Banner Start/End Date must between Work Order Campaign Start/End Date.");
    return;
}

I tested it on Chrome and it's ok. But, when I tried to test it using Mozilla Firefox, why it's failed? I am using this example:

workOrderCampaignStartDateTime  = "2014-07-18 15:40";
workorderCampaignEndDateTime    = "2014-07-18 16:00";
bannerStartDateTime             = "2014-07-18 15:40";
bannerEndDateTime               = "2014-07-18 16:00";

It's work in Chrome but not in Mozilla Firefox.


Solution

  • I checked this code and it works in my Firefox browser.

    Why don't you use javasript Date object, for example:

    bannerEndDateTime= new Date(year, month, day, hours, minutes)