How to remove temporary part from javascript date?

I have a date '12/12/1955 12:00:00 AM'stored in a hidden column. I want to display the date without time. How do I do this?

+15
source share
3 answers

Divide it into spaceand take the first part as shown below. Hope this helps you.

var d = '12/12/1955 12:00:00 AM';
d = d.split(' ')[0];
console.log(d);
+18
source

Divide this line into an object Date:

var myDate = new Date('12/12/1955 12:00:00 AM');

Then use the usual methods to get the day / month / year date .

+13
source

, , :

new Date(<your-date-object>.toDateString());

: :

new Date(new Date().toDateString());

gives: Thu July 11, 2019 00:00:00 GMT-0400 (Eastern Daylight Time)

0
source

Source: https://habr.com/ru/post/1623760/


All Articles