Question

I have code:

var date = '2014/01/01';
date = new Date(Date.parse(date));
date = date.toString();

I get string like this - "Wed Jan 01 2014 00:00:00 GMT+0400 (MSK)". It's good, but in my case i need to get string without "(MSK)"

I need - "Wed Jan 01 2014 00:00:00 GMT+0400" only!

How can i do it? Thanks in advance!

Was it helpful?

Solution

If its a string, just do something like:

date = date.toString(); date = date.replace(/\([A-Z]+\)$/,"");

You could also change the format by passing in a new value to date.toString("%format%"), as per:

http://msdn.microsoft.com/en-us/library/az4se3k1%28v=vs.110%29.aspx

..but for what you need, simply doing the replacement would be the easiest :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top