Separate Date and time with AM or PM by converting string to array and access its member - Javascript Date Operation

Javascript examples for Date Operation:Time Format

Description

Separate Date and time with AM or PM by converting string to array and access its member

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/* www.  ja  v  a  2 s.c o  m*/
selectedDateTime = "2009-08-12 14:30:00 AM"
var splitarray = new Array();
splitarray= selectedDateTime.split(" ");
var date = splitarray[0];
var time = splitarray[1] + splitarray[2];
console.log("Date: "+ date + "  Time: " + time)
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials