thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.78k stars 2.67k forks source link

Media manager - Set the date to local #5599

Open toto975 opened 2 years ago

toto975 commented 2 years ago

Laravel version

9.x

PHP version

8.4.1

Voyager version

1.5

Description of problem

The date are formated in US Format in media manager

image

Proposed solution

in vendor\tcg\voyager\resources\views\media\manager.blade.php, change

dateFilter: function(date) {
    if (!date) {
        return null;
    }
    var date = new Date(date * 1000);

    var month = "0" + (date.getMonth() + 1);
    var minutes = "0" + date.getMinutes();
    var seconds = "0" + date.getSeconds();

    var dateFormated = date.getFullYear() + '-' + month.substr(-2) + '-' + date.getDate() + ' ' + date.getHours() + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);

    return dateFormated;
},

to

dateFilter: function(date) {
    if (!date) {
        return null;
    }
    var date = new Date(date * 1000);
    return date.toLocaleString();
},

image

Alternatives considered

No response

Additional context

No response

fletch3555 commented 2 years ago

Wait, is that what our code is currently doing? I have to agree, that's pretty terrible. We're absolutely open to PRs for this