[Javascript] varST & quot; 2010-5-139: 22: 10 & quot;, // start time: ET & quot; 2010-5-& quot ;, // startTimeMyFormatTime (ST ). getTime (), endTimeMyFormatTime (ET ). getTime (); I
[Javascript]
Var ST = "9:22:10", // start time
ET = "9:22:11", // End Time
StartTime = MyFormatTime (ST). getTime (),
EndTime = MyFormatTime (ET). getTime ();
If (startTime> endTime ){
Document. write ("End Time:" + ST + "earlier than start time:" + ET );
} Else if (startTime Document. write ("End Time:" + ET + "greater than the start time:" + ST );
} Else {
Document. write ("End Time:" + ET + "equals to start time:" + ST );
};
Function MyFormatTime (str ){
Var year = str. split ('-') [0];
Var month = str. split ('-') [1];
Var date = str. split ('-') [2]. split ('') [0];
Var h = str. split ('-') [2]. split ('') [1]. split (':') [0];
Var m = str. split ('-') [2]. split ('') [1]. split (':') [1];
Var s = str. split ('-') [2]. split ('') [1]. split (':') [2];
Return new Date (year, month, date, h, m, s );
};
Var ST = "9:22:10", // start time
ET = "9:22:11", // End Time
StartTime = MyFormatTime (ST). getTime (),
EndTime = MyFormatTime (ET). getTime ();
If (startTime> endTime ){
Document. write ("End Time:" + ST + "earlier than start time:" + ET );
} Else if (startTime Document. write ("End Time:" + ET + "greater than the start time:" + ST );
} Else {
Document. write ("End Time:" + ET + "equals to start time:" + ST );
};
Function MyFormatTime (str ){
Var year = str. split ('-') [0];
Var month = str. split ('-') [1];
Var date = str. split ('-') [2]. split ('') [0];
Var h = str. split ('-') [2]. split ('') [1]. split (':') [0];
Var m = str. split ('-') [2]. split ('') [1]. split (':') [1];
Var s = str. split ('-') [2]. split ('') [1]. split (':') [2];
Return new Date (year, month, date, h, m, s );
};