Shiv Shiv - 10 months ago 70
Javascript Question

Remove GMT+530(Indian standard Time) without changing current time in javascript

I am displaying current day,month,date,year and time like this

Mon Oct 24 2016 17:09:25 GMT+0530 (India Standard Time)​​​​​​​

but i need to display like this

Mon Oct 24 2016 17:09:25

my code in javascript:

var timestamp = new Date();
editor.insertHtml( 'The current date and time is: ' + timestamp.toString());

How can i do this please can anyone tell me how to do this.

Thank you

Answer Source

If you are open to add a library, you should use moment.js

console.log(moment().format('ddd MMM DD YYYY hh:mm:ss'))
<script src=""></script>

If not, a small work around

var d = new Date().toString();
var index = d.lastIndexOf(':') +3
console.log(d.substring(0, index))

Note: moment approach is more preferred