Javascript to get date & time without chars and spaces

I need a javascript that will get the current date time and then strip off all spaces and chars.  

For example;

Fri 01 22 2016 20:09:23 GMT-0500 (Eastern Standard Time)

Remove all spaces and chars:  01222016200923
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I recommend using the moment.js Javascript project. It makes working with dates very easy. See this plunker for an example.

There are two steps to using:
1: Include the project dependency.
<script src=""></script>

Open in new window

2: Convert your date.
      var formatDate= 'Fri 01 22 2016 20:09:23 GMT-0500 (Eastern Standard Time)';
      var responseDate = moment(formatDate).format('MMDDYYYYHHmmss');

Open in new window

function cleanDate(str){
return str.replace(/ GMT.+$/g,'').replace(/\D/g,'');

var str='Fri 01 22 2016 20:09:23 GMT-0500 (Eastern Standard Time)';

var result = cleanDate(str);
alert( result );

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewIT / Software Engineering ConsultantCommented:
If you do want to do it in just native JavaScript, then here is a straight forward (not overly clever) approach.  A couple of functions that then take a date and format as you wanted.

var d = new Date()

function fmtdate(d) {
    return d.getFullYear()+zpad2(d.getMonth()+1)+zpad2(d.getDate())+zpad2(d.getHours())+zpad2(d.getMinutes())+zpad2(d.getSeconds())

function zpad2(n) {
    if (n<10) { n = ("0"+n); }
    return n;

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.