Skip to content

formatDateTime #71

Description

@mekibe

hello shows someone how I can add the 24 hour format or would like to remove am and pm need help with please

function formatDateTime(date) {
var now = new Date();
var zpad_mins = ':' + (date.getMinutes() < 10 ? '0' : '') + date.getMinutes();
if (date.getYear() != now.getYear()) {
return '' + (1900 + date.getYear());
} else if ((date.getMonth() != now.getMonth()) ||
(date.getDate() != now.getDate())) {
return date.getDate() + ' ' + chrome.i18n.getMessage(
'month' + date.getMonth() + 'abbr');
} else if (date.getHours() == 12) {
return '12' + zpad_mins + 'pm';
} else if (date.getHours() > 12) {
return (date.getHours() - 12) + zpad_mins + 'pm';
}
return date.getHours() + zpad_mins + 'am';
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions