JavaScript-Remove everything after a certain character and string compare

function myFunction() {
    var str1 = "15.09.2012 19:30";
    var str2 = new Date().format("dd.mm.yyyy");
    var result = "";

    var str3 = str1.substring(0, str1.indexOf(' ')); //str3= "15.09.2012"

    var isEqual = str2.localeCompare(str3);
    if (isEqual == 0)
        result = str3 + ' and ' + str2 + ' are same!';
    else
        result = str3 + ' and ' + str2 + ' are different!';
}

Comments

Popular posts from this blog

Solution for the fault: "System.Diagnostics.Process.Start is not working on IIS, but working on ASP.NET Development Server"

Solution for "Can not obtain Oracle client information from registry"