-2

Given the data 2018-04-28T18:38:23Z

When I use Date(2018-04-28T18:38:23Z)

This gives me Sat Apr 28 2018 18:38:23 GMT-0500

I want to remove that GMT thing, but how can I do with simply without

writing some long code to parse it out?

Dawn17
  • 5,159
  • 8
  • 32
  • 79
  • You can style the date any way you wish. It will require some lines of code, but not many. See here https://www.w3schools.com/js/js_date_methods.asp – ecg8 Apr 28 '18 at 23:44
  • @ecg8—please don't reference w3schools, [*MDN*](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) and [*ECMA-262*](http://ecma-international.org/ecma-262/8.0/#sec-date-objects) are much better resources. – RobG Apr 29 '18 at 01:38
  • @RobG, both those are great sites, but so is w3schools. I learned a lot of shit from them. – ecg8 Apr 29 '18 at 02:22
  • @ecg8—unfortunately it's full of errors, such as "*The getFullYear() method returns the year of a date as a four digit number*", which is simply wrong. The benefit of MDN is that being a public wiki, anyone can fix such errors as soon as they are found and a dedicated band of maintainers keeps it up to date. – RobG Apr 29 '18 at 03:10

1 Answers1

1

JavaScript Date has some methods you could use to craft the String you want.

Here's something close, you could play around with the methods (getHours/Minutes/Seconds), but if you want exactly that without the timezone, I would recommend parsing out or doing some String manipulation:

var d = new Date();
console.log(d.toDateString() + " " + d.toLocaleTimeString());

// Output:   
// Sat Apr 28 2018 4:58:05 PM
cheriejw
  • 324
  • 1
  • 13