Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

How to remove the "seconds" with regular expression

$
0
0

the following regular expression is supposed to remove the "seconds" component.  it works in Firefox and chrome but not IE 11 or Edge.

var retval = new Date().toLocaleTimeString();
retval = retval.replace(/(\d{1,2}:\d{2}):\d{2}/, "$1");

// this is how it should convert

"‎9‎:44‎:24‎ ‎AM" => "‎9‎:44‎ ‎AM"


Viewing all articles
Browse latest Browse all 3527


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>