explorer icon indicating copy to clipboard operation
explorer copied to clipboard

gmt timezone change

Open create0122 opened this issue 7 years ago • 7 comments

How can i change the timezone on the explorer?

create0122 avatar Mar 11 '18 05:03 create0122

same here

cryptozeny avatar Nov 20 '18 10:11 cryptozeny

i did it :sweat_smile: toTimeString() set time to your current timezone.

https://github.com/sugarchain-project/explorer/commit/af9515b18da47f9ee94a99b03dc12e2e0600ce36

cryptozeny avatar Nov 21 '18 17:11 cryptozeny

sorry it has some bug. i will find another way

cryptozeny avatar Nov 30 '18 18:11 cryptozeny

Does the above commit work or is there still a bug?

farsider350 avatar Nov 11 '19 10:11 farsider350

still no way

cryptozeny avatar Nov 11 '19 10:11 cryptozeny

with some code changes (and by adding moment-timezone, like from cdnjs) you can just make it so the browser timezone is used. quick and dirty tho, but works on modern browsers.

for the index, movement and address_history view you can add something like this to the right parts of document.ready function

        var mom = moment(data[0]);
        var client_tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
        var timestamp = mom.tz(client_tz).format('dddd, Do of MMMM YYYY, HH:mm:ss zz');

for the block and tx view you'll need to change the template so the table cells containing the timestamp have an ID, i.e.:

              td.d-none.d-sm-table-cell.d-table-cell#blocktime=time

then use similar code like above to "momentjs over the generated page" before rendering, clientside.

i.e.

  script.
    $(document).ready(function(){
      moment.locale(navigator.languages[0]);
      var mom = moment($("#blocktime"));
      var client_tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
      var timestamp = mom.tz(client_tz).format('dddd, Do of MMMM YYYY, HH:mm:ss zz');
      $("#blocktime").text(timestamp);
    });

i know this is like superhackish, but works for me. @TheHolyRoger if you would like to have a PR with this, let me know.

BloodyNora avatar Dec 20 '20 00:12 BloodyNora

for reference, i have just put the "local timestamps" feature to production at https://explorer.verus.io/

BloodyNora avatar Dec 21 '20 21:12 BloodyNora