Search code examples
javascriptphpjquerytwitter-bootstrapcodeigniter

Extract date from long complicated date plus time stamp?


I am using bootstrap calendar and on clicking any particular date I got complicated date in this form:

Sat Sep 06 2014 00:00:00 GMT 0500 (Pakistan Standard Time)

Can anybody please tell me how I can extract only date from this complicated long date?

I am working in PHP codeignitor, is there any way in PHP or JavaScript through which I can only extract date?


Solution

  • if this is for Javascript then just use this:

    var myDate = new Date('Sat Sep 06 2014 00:00:00 GMT 0500 (Pakistan Standard Time)');
    

    after that you can use myDate as a date object and call its methods like myDate.getFullYear() etc.