Reputation: 39
I am getting 2018-06-10 00:29:04
this type of value in the key date. I just want to display date without time.
I want to have 2018-06-10
from 2018-06-10 00:29:04
.
Upvotes: 0
Views: 270
Reputation: 1104
If it's a fixed string that you're working with, as in you know it'll always be in that format, you can just truncate it like so:
var datetimestamp = "2018-06-10 00:29:04";
var dateTruncated = datetimestamp.slice(0, 10);
If it's not fixed, you can split on spaces like @Shubh mentioned in his comment and take the first array value.
Upvotes: 1