Im trying to get the date, but im wanting to to return ex ”Oct 29”
. Ive tryed using split, but it changes everyday. Heres what I have so far.
Let date = Date().split(“ 2021”)[0];
This returns day<string> month day<int>
Im trying to get the date, but im wanting to to return ex ”Oct 29”
. Ive tryed using split, but it changes everyday. Heres what I have so far.
Let date = Date().split(“ 2021”)[0];
This returns day<string> month day<int>
You can format it there are various inbuilt methods or do this:
Let date = Date().toString().substring(4,10);
You can use the toLocaleString
function to achieve what you want. This code below will generate the output you wanted ("Oct 29"
).
let date = new Date().toLocaleString('en-US', { month: 'short', day: 'numeric' });