Here is my code:
let dateStr = m.status?.match(/at (.* GMT)/)?.[1] || m.dateTimeGMT;
// Parse it safely
const dateObj = new Date(dateStr);
// Options for human-readable format
const options = {
weekday: 'short', // Fri
year: 'numeric', // 2001 (will be replaced)
month: 'short', // Nov
day: 'numeric', // 14
hour: '2-digit',
minute: '2-digit',
hour12: false // 24-hour format
};
let localDate = dateObj.toLocaleString(undefined, options);
localDate = localDate.replace("2001", "2025");
console.log(localDate); // Fri, 14 Nov 2025, 14:30
I implemented cricket live streaming API on my website https://tamashaapp.com, check its home page, the date is showing 14 Nov 2001 instead of 14 Nov 2025.
What is wrong with this code so it shows the exact date format?
Note: for the time being, I use this code localDate = localDate.replace("2001", "2025"); to replace 2001 to 2025, but its not a professional way.
m? Please edit your question to include a minimal reproducible example.dateStris, it's very unlikely that anybody can help you.