Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to get current timezone in javascript? [duplicate]

Tags:

javascript

Possible Duplicate:
Getting the client’s timezone in JavaScript

Is there anyway to get current timezone in javascript. All i see is

Date.getTimeZoneOffset()

The problem I am facing is, I have a piece of functionality which allows the users to download pdf, now the pdf has to include a 'download date' in it which should be users local date, have to do this in java. But its all confusing, I dont know if i should locale or not or just the timezone will work, each time when i try something the results are different!!!!

like image 291
Toseef Zafar Avatar asked Nov 01 '25 04:11

Toseef Zafar


1 Answers

Use Date.toTimeString()

Code:

var date = new Date();
document.write(date.toTimeString());

Output:

22:53:21 GMT+0530 (India Standard Time)
              ^offset     ^timezone
like image 185
Anirudh Ramanathan Avatar answered Nov 03 '25 18:11

Anirudh Ramanathan