Jump to content

add + 30 minutes in clock


Recommended Posts

Good day, i'll want to add 30 minutes on clock. This is my current script:

 

 

<script type="text/javascript">

<!--

var currentTime = new Date()

var hours = currentTime.getHours()

var minutes = currentTime.getMinutes()

if (minutes < 10){

minutes = "0" + minutes

}

document.write(hours + ":" + minutes + " ")

if(hours > 11){

document.write("PM")

} else {

document.write("AM")

}

 

//-->

</script>

</h4>

 

Thank you :D !

Link to comment
Share on other sites

you cna add in any tpl file section of your theme, but place a {literal} before the script and {/literal} at the end

 

the current javascript is correct and i can see clock correctly, but i'd want add a form that add 30 minutes!

for example: now are 13.45 + 30 minutes = 2.15 !

 

how i can add 30 minutes!?

Link to comment
Share on other sites

The question was not difficult...by the way, this is the solution for "add + minutes" :

 

 

<script type="text/javascript">

 

<!--

 

var twentyMinutesLater = new Date()

 

twentyMinutesLater.setMinutes(twentyMinutesLater.getMinutes() + 30);

 

var ore = twentyMinutesLater.getHours()

 

var minuti = twentyMinutesLater.getMinutes()

 

 

 

if (minuti < 10)

 

minuti = "0" + minuti

 

 

 

var suffix = "AM";

 

if (ore >= 24) {

 

suffix = "PM";

 

ore = ore - 24; }

 

if (ore == 0) {

 

ore = 00;}

 

 

if (ore < 10) {

 

ore = "0" + ore }

 

document.write(ore + ":" + minuti + " ")

 

//-->

 

</javascript>

Link to comment
Share on other sites

×
×
  • Create New...