title: Javascript Date() function not working in Safari (iOS)
body: <p>I am using Date() function to get current date and compare it to another date.</p>
  
  <p>It's working fine with Android and web but it's not working in iOS .</p>
  
  <p>My code is:</p>
  
  <pre><code>function daytogo()
          {
                var status = document.getElementById('dmy_status').getAttribute('value');
              if(status =='C')
              {
                  var event_status="Event has been cancelled";
              }
              else if(status =='P')
  
              {
                  var event_status="Event postponed ! Waiting for new date";
              }
              else
              {
                          /*START OF CALCULATING DATE DIFFERENCE*/
                      var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
  
                      var a = document.getElementById('dmy_strt').getAttribute('value');
                      var b = document.getElementById('dmy_end').getAttribute('value');
                      //var firstDate = new Date(2008,01,12);
                     // alert(b);
                      //alert(firstDate);
                      var today = new Date();
                      var dd = today.getDate();
                      var mm = today.getMonth()+1; //January is 0!
                      var yyyy = today.getFullYear();
  
                      if(dd&lt;10) {
                          dd='0'+dd
                      } 
  
                      if(mm&lt;10) {
                          mm='0'+mm
                      }
  
                      today = yyyy+','+mm+','+dd;
                      // document.write(today);
                         var firstDate = new Date(a);
                         var secondDate = new Date(today);
                         var enddate=new Date(b);
                         console.log(firstDate);
                         console.log(secondDate);
                      // alert(today);
                      //    var diffDays = Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay));
                   //    alert(diffDays);
                        if(firstDate &gt; secondDate)
                         {
                                  alert("if");
                                  var event_status='';
                                  var diffDays = Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay));
                                  //alert(diffDays);
                                  if(diffDays &lt;=30 )
                                  {
                                       event_status=diffDays + " days to go";
                                  } 
                                  else
                                  {
                                      event_status=(diffDays /30);
                                      event_status=(event_status.toString().split(".")[0])+ ' months to go'; ///before
                                      //alert(event_status.toString().split(".")[1]); ///after
                                  }
                          }
                          else if(firstDate &lt;= secondDate &amp;&amp; enddate &gt;= secondDate)
                          {
                              alert("else if");
                              var event_status='Ongoing';
                          }
                          else
                          {
                               alert("else");
                                  var event_status="Event has expired";
                                  //document.getElementById("days_to_go").innerHTML = event_status;
                          }
                       //var elements = document.getElementsByClassName('dmy_strt')[0].value;
                      /*END OF THE DATE DIFFERENCE*/ 
  
  
                      /*START OF EVENT STATUS */
  
  
              }
  
              document.getElementById("days_to_go").innerHTML = event_status;
  </code></pre>
  
  <p>And date format is - 'YYYY,mm,dd'
  and I have tried 'YYYY/mm/dd' format also.</p>
  
  <p>But in case of iOS it's going to else case always (var event_status="Event has expired";).</p>
  
  <p>How can I solve this?</p>