How to add time display with seconds to this working date code. Time should be shown UTC +1. And is it possible for it to automatically switch to winter and summer time?
Unfortunately, I don’t understand script programming.
Here is the working code that I have
var d = new Date();
var day=new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var month=new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
document.write(day[d.getDay()]+" " +d.getDate()+ " " + month[d.getMonth()]
+ " " + d.getFullYear() + " Year.");
2
Answers
You can use
getSeconds
&getMinutes
methodsTo add the time display with seconds to your existing date code and show it in UTC+1 (with automatic switching between summer and winter time), you can update your script as follows:
Explanation:
getTimezoneOffset()
method is used to account for the difference between UTC and local time.This script should display the correct date and time in UTC+1, accounting for both summer and winter time.