JavaScript Using toLocaleString() on document.lastModified in Javascript

I have a little script at the bottom of the webpage with the following:

<script language="Javascript">
    var d = document.lastModified;
    var n = d.toLocaleString();
    document.write("These documents were last modified on: " + n +"");
</script>

However, the date is not modified to my local timezone. I have tried on other peoples' systems (our OS's are definitely English UK). Any idea why?

Thanks,

Harry

Answer:1

If you have php installed check the php ini. Look for timezone and alter it.

List of Supported Timezones

http://php.net/manual/en/timezones.php

 // php.ini example  

   [Date]
    ; Defines the default timezone used by the date functions
    ; http://php.net/date.timezone
    date.timezone=Europe/Berlin

This script could also work. It gives you your device's time zone setting. https://bitbucket.org/pellepim/jstimezonedetect

I like to add this to my webapps so I can always get the user's timezone.

// example implementation 

<script>

$(function() {
  // Get user's timezone
  var tz = jstz.determine();
  timezone = tz.name();

  $('#tz_field').attr('value', timezone);
});
</script>
Answer:2

I'm new to PHP and very lost. I'm working with HTML5, CSS3, jQuery and Bootstrap 4. I have a total of 4 HTML pages on my website. In the first page there are 4 squares with text (let's say A, B, C ...

I'm new to PHP and very lost. I'm working with HTML5, CSS3, jQuery and Bootstrap 4. I have a total of 4 HTML pages on my website. In the first page there are 4 squares with text (let's say A, B, C ...

  1. passing data among methods in java

I want to push all the item-data into one array. However, when I try, it just makes an array for every item. async function final() { const response = await fetch('/api'); const data = await ...

I want to push all the item-data into one array. However, when I try, it just makes an array for every item. async function final() { const response = await fetch('/api'); const data = await ...

I have html like this: <div class="item"> <img class="item-image" src="${item.getImage()}"/> <p>${item.getName()}</p> </div> and Javascript: var classname = ...

I have html like this: <div class="item"> <img class="item-image" src="${item.getImage()}"/> <p>${item.getName()}</p> </div> and Javascript: var classname = ...

  1. getelementsbyclassname javascript only

I have below array how to get list of names where the age is greater than 18. so the out put should be: ["Anna", "Bob"] friends = [{ name: 'Anna', books: ['Bible', 'Harry Potter'], age: 21 }, ...

I have below array how to get list of names where the age is greater than 18. so the out put should be: ["Anna", "Bob"] friends = [{ name: 'Anna', books: ['Bible', 'Harry Potter'], age: 21 }, ...

  1. array from properties file
  2. array properties in javascript
  3. array properties in c#
  4. array properties in java
  5. array properties in js
  6. array properties in python
  7. array properties in php
  8. array properties in swift
  9. array properties in vba
  10. array properties in data structure
  11. array properties in typescript
  12. array properties in angular 2
  13. array properties in angular 6
  14. array properties in vb.net
  15. array properties in matlab
  16. array properties in powershell
  17. array in properties file spring
  18. array in properties file java
  19. array of properties
  20. array in properties spring