I am doing some work with displaying the local time.
I would like to get this format:
2:18:00 pm
Using the sample code from w3Schools.com below, I can get the correct results from IE and FireFox. But when it comes to Chrome, I get the 24hr clock version where it is simply displayed this way:
14:18:00
http://xn--www-5da33as14n.w3sc hools.com/jsref/jsref_tolocalet imestring.asp
What setting is there in Chrome or what code do I need to write to get the desired format from Chrome?
I would like to get this format:
2:18:00 pm
Using the sample code from w3Schools.com below, I can get the correct results from IE and FireFox. But when it comes to Chrome, I get the 24hr clock version where it is simply displayed this way:
14:18:00
http://xn--www-5da33as14n.w3sc hools.com/jsref/jsref_tolocalet imestring.asp
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Getting Local Time </title>
</head>
<body>
<script type="text/javascript">
var d=new Date();
document.write("Original form: ");
document.write(d + "<br />");
document.write("Formatted form: ");
document.write(d.toLocaleTimeString());
</script>
</body>
</html>
Comment