//condition if status is shown as active or inactive
function getshiftstatus(start_datetime, end_datetime) {
var s_status = '';
if (start_datetime === null) {
s_status = '<p class="text-danger font-weight-bold">Inactive</p>';
} else if (end_datetime === null) {
s_status = '<p class="text-success font-weight-bold">Active</p>';
} else {
s_status = `<table>
<tr class="row-gray">
<td class="p-0 font-weight-bold">From:</td>
<td class="tb-schedule">${start_datetime}</td>
</tr><tr class="row-gray">
<td class="p-0 font-weight-bold">To:</td>
<td class="tb-schedule">${end_datetime}</td>
</tr>
</table>`;
}
return s_status;
}
These two functions: ${start_datetime}
and ${end_datetime}
output a date with time, but in my case I just want to show the date only how do I format my code to do this?
Like in the screenshot, I am aiming for the same output without the 24 hour time
Here are the SQL columns:
If you are certain the date will always be separated with an empty space then you should split the string and get the first half that contains the date.
const dateTime = '2021-08-13 01:19:26';
const getDate = dateTime => {
const [date] = dateTime.split(' ')
return date
}
console.log(getDate(dateTime))