vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Forum Home Enhancements - Clock In Navbar (https://vborg.vbsupport.ru/showthread.php?t=139314)

msalman 06-14-2007 10:42 AM

Quote:

Originally Posted by Alibass (Post 1267793)
I have tried your modified version and it looks great. Did notice from 12pm to 1pm the clock showed AM and switch to PM when the clock rolled to 1pm. Any suggestions?

there's small silly mistake, you just need to make a small change

Replace the following line
Code:

if (h > 12)
with
Code:

if (h >= 12)
Quote:

Originally Posted by Alibass;
Works good on 3.6.7PL1, but when viewing thread the clock constantly shows Loading Clock.....

Here's the fixed version of it

replace what you have before with this
Code:

<b><div id="txt"><b>$vbphrase[loading_clock]</b></div></b>

<script type="text/javascript">
function startTime()
{
var today = new Date()
var h = today.getHours()
var m = today.getMinutes()
var s = today.getSeconds()
var day = today.getDay()
var date = today.getDate()
var month = today.getMonth()
var year = today.getFullYear()
var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var months = new Array(" January"," February"," March"," April"," May"," June"," July"," August"," September"," October"," November"," December")
var am_pm

if (h >= 12) {
    h -= 12
    am_pm = "P.M."
}
else {
    am_pm ="A.M."
}

// add a zero in front of numbers<10
m = checkTime(m)
s = checkTime(s)
h = checkTime(h)
document.getElementById('txt').innerHTML = days[day] + " " + date + months[month] + " " + year + ", " + h + ":" + m + ":" + s + " " + am_pm
setTimeout("startTime()", 1000)
}

function checkTime(i)
{
if (i < 10)
  {i = "0" + i}
  return i
}
startTime()
</script>


Alibass 06-14-2007 12:11 PM

@msalman

Thanks m8 for the new code. This seemed to have fixed the Clock Loading..... error also while viewing a thread. :)

Alibass 07-02-2007 04:14 PM

@msalman

Actually your code is for a 24 hour clock and works best that way. If you try and use it as a 12 hour clock then midnight is shown as 00:00:00 AM instead on 12:00:00 AM and noon is shown 00:00:00 PM instead of 12:00:00 PM

Find
Code:

if (h >= 12) {
    h -= 12
    am_pm = "P.M."
}
else {
    am_pm = "A.M."
}

Replace (for 24 hour clock)
Code:

if (h >= 12) {
    h <= 12
    am_pm = ""
}
else {
    am_pm = ""
}


sadsack 12-10-2007 12:50 AM

Quote:

Originally Posted by Alibass (Post 1281393)
@msalman

Actually your code is for a 24 hour clock and works best that way. If you try and use it as a 12 hour clock then midnight is shown as 00:00:00 AM instead on 12:00:00 AM and noon is shown 00:00:00 PM instead of 12:00:00 PM

Find
Code:

if (h >= 12) {
    h -= 12
    am_pm = "P.M."
}
else {
    am_pm = "A.M."
}

Replace (for 24 hour clock)
Code:

if (h >= 12) {
    h <= 12
    am_pm = ""
}
else {
    am_pm = ""
}



Excellent, did the trick first time, thanks.


All times are GMT. The time now is 07:22 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01885 seconds
  • Memory Usage 1,731KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete