How to Get The Country Wise Date and Time Using Jquery
In this tutorial, we will tell you how to get the country wise date and time. you can use the below code to get country wise timezone or date.
here, we will use getTime and getTimezoneOffset function in this below example. it’s the function to convert date and timezone.
see below example, I think can help you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <script> function calcTime(city, offset) { d = new Date(); utc = d.getTime() + (d.getTimezoneOffset() * 60000); convert = new Date(utc + (3600000*offset)); return "The local time in " + city + " is " + convert.toLocaleString(); } // get Bombay time console.log(calcTime('Bombay', '+5.5')); // get Singapore time console.log(calcTime('Singapore', '+8')); // get London time console.log(calcTime('London', '+1')); </script> |
Please follow and like us: