I want this string:
var time = '02/19/2014';
to look like:
var time = '20140219';
That is, I want the format mm/dd/yyyy to "be regexed" into yyyymmdd.
I want this string:
var time = '02/19/2014';
to look like:
var time = '20140219';
That is, I want the format mm/dd/yyyy to "be regexed" into yyyymmdd.
Try:
var time = '02/19/2014';
time = time.replace(/(\d+)\/(\d+)\/(\d+)/, '$3$1$2');
How about some simple string manipulation?
time = time.substr(6, 4) + time.substr(0, 2) + time.substr(3, 2);
As you can see, string consists of three blocks, divided by slashes. I propose you to do the following: pattern as (\d{2}) / (\d{2}) / (\d{4}), and replacement as $3$1$2 (without spaces). It is written in php, but I hope that you can easily convert it into your language.