0

I want to display a label showing the current time: I used to get the current time in 'hh:mm:ss':

var dt = new Date();
var time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();

o/p: Data current as of 14:20:35

now how can i convert this time into an hourly format: Data current as of 2:30pm-PST ( assuming the current time is 2:30pm)? Any ideas?? Thanks!

user1234
  • 3,000
  • 4
  • 50
  • 102
  • Uhm, if I understand your question, wouldn't that just be `var time = dt.getHours() + ":" + dt.getMinutes();` for yoou? – Joeytje50 Dec 21 '14 at 22:27
  • 1
    PS: You don't have to favourite each of your own questions; you can find them back in the Questions tab on your profile: http://stackoverflow.com/users/4021059/user1234?tab=questions – Joeytje50 Dec 21 '14 at 22:28
  • 2
    Do you want to achieve something like this ? http://stackoverflow.com/questions/8888491/how-do-you-display-javascript-datetime-in-12-hour-am-pm-format – Bali Balo Dec 21 '14 at 22:53
  • @BaliBalo: thanks, yes looking something similar to that! is there any way to get the timezone as well???Eg: 4:00pm PST? – user1234 Dec 22 '14 at 00:03
  • found the answer: function getTimeZone() { return /\((.*)\)/.exec(new Date().toString())[1]; } getTimeZone(); – user1234 Dec 22 '14 at 00:16

0 Answers0