To show a Clock on the WordPress website, I'm using a simple code suggested at the following link:
- JavaScript Clock — plus2net.com
I changed the display function to:
function display_ct() {
var strcount
var now = new Date();
var d = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds() );
// obtain local UTC offset and convert to msec
localOffset = now.getTimezoneOffset() * 60000;
var c = new Date(d + localOffset);
document.getElementById('ct').innerHTML = c;
tt=display_c();
}
So that it's showing:
Sun Jul 20 2014 14:57:47 GMT+0600 (Central Asia Standard Time)
The site is a Bangladesh-based site, so I need to show the time to be GMT+6
always. But I want to format the display like below:
Dhaka: Jul 20 2014 02:57:47 PM
I know I can show the string Dhaka:
, but I can't modify the view of the JS to this. I've checked getFullYear()
, getMonth()
etc. but each time they are returning single value. How come the large output comes out from the date()
function then? I din't check my code otherwise Dhaka.
I'm sorry, I'm novice in JavaScripting. :(