JavaScript Adding UTC time to my countdown timer

I recently was searching after a countdown script that count down to a specific day, hour and minute and reset again after it reached the time.

Now a week later i see a major issue in the script. The countdown is based on local time and this is a problem.

I want to have the countdown based on the UTC time and not the local pc time. Anyone that can help me with this because i'm not sure how to do this. I made also a clock script that i use and there i could say ".getUTC..." but i have no idea how to implement that in this script because i picked it up from the internet.

I'm not very good in javascript/jquery and i'm still learning a lot. I can mostely understand the scripts but i miss the lack of writing it myself so it would be very nice if you could edit the script so it's based on the UTC time and tell me a bit about it so i can learn from it. I really would appriciate that !

Thanks a lot, Jens

var EVENTDAY = 1; // monday
var EVENTHOUR = 22; //
var EVENTMINUTE = 42; //
    
function getRemaining( now )
{
    if ( now == null ) now = new Date();

    var dow = now.getDay();
    // the "hour" for now must include fractional parts of the hour, so...
    var hour = now.getHours() + now.getMinutes()/60 + now.getSeconds()/3600;

    // how many days from current day until event day?
    var offset = EVENTDAY - dow;

    // if event day is past *OR* if today is the event day but the event time is past...
    if ( offset < 0 || ( offset == 0 && EVENTHOUR < hour ) )
    {
        // we are past the event time in current week, so 
        // target EVENTDAY is next week:
        offset += 7; 
    }

    // so this date (day of the month) is the next occurrence of the event:
    var eventDate = now.getDate() + offset; 

    // and so then next occurrence of the event is at this time:
    var eventTime = new Date( now.getFullYear(), now.getMonth(), eventDate, 
                              EVENTHOUR, EVENTMINUTE, 0 ); 

    // this is how many milliseconds from now to the next event occurrence
    var millis = eventTime.getTime() - now.getTime();

    // convert milliseconds to days/hours/minutes/seconds:
    var seconds = Math.round( millis / 1000 );
    var minutes = Math.floor( seconds / 60 );
    seconds %= 60;
    var hours = Math.floor( minutes / 60);
    minutes %= 60;
    var days = Math.floor( hours / 24 );
    hours %= 24;
    if ( seconds < 10 ) seconds = "0" + seconds;
    if ( minutes < 10 ) minutes = "0" + minutes;
    if ( hours < 10 ) hours = "0" + hours;
    if ( days == 1 ) {
	days = days + " day, ";
    } 
    else {
	days = days + " days, ";
    }
    // and return that formatted pretty:
    return days + hours + ":" + minutes + ":" + seconds;
    
}

function tick()
{
    // this is the automatic once a second display:
    document.getElementById("countdown").innerHTML = getRemaining();
}
setInterval( tick, 1000 ); // specifies once a second

// here is a demo that allows you to test the function 
// by specifying a date and time in the <form> below
function demo( form )
{
    var t = form.theDate.value.split("/");
    var mn = Number(t[0]);
    var dy = Number(t[1]);
    var yr = Number(t[2]);
    var t = form.theTime.value.split(":");
    var hr = Number(t[0]);
    var mi = Number(t[1]);
    var sc = Number(t[2]);
    // so this is the test date/time that you specified:
    var test = new Date( yr, mn-1, dy, hr, mi, sc );

    // and here we call the master function and put its answer in the <form>:
    form.remaining.value = getRemaining( test );
}
Answer:1

using Jcounter

Change line 34 in the jquery.jCounter-0.1.4.js file

serverDateSource: '/pathtofile/dateandtime.php', //path to dateandtime.php file (i.e. http://my-domain.com/dateandtime.php)

in the dateandtime.php file

<?php
ini_set('display_errors', 0); error_reporting(E_ALL);

date_default_timezone_set("Pacific/Auckland");  // CHANGE HERE
// GMT +12
if (isset($_GET['timezone'])) {
$timezone = new DateTimeZone($_GET['timezone']);
} else {
$timezone = new DateTimeZone("Pacific/Auckland");//CHANGE HERE
}
$date = new DateTime();
$date->setTimezone($timezone);
$dateAndTime = array("currentDate"=>$date->format('d F Y H:i:s'));
echo $_GET['callback'] . '(' . json_encode($dateAndTime) . ')';
?>

Then in you countdown timer file have it setup something like this:

<?php
date_default_timezone_set("Pacific/Auckland");//GMT+12 <--- CHANGE THIS
//Set your date and time below.
$day = date("D");
$hour = date("H");
if ($day=="Sun" && $hour>='9') {$date = date('d F Y H:i:s', strtotime('next Sunday 09:00:00'));}
else {$date = date('d F Y H:i:s', strtotime('this Sunday 09:00:00'));}
?>
<script type="text/javascript">
    $(document).ready(function() {
        $(".mycountdownname").jCounter({
            animation: "slide",
            date: "<?=$date?>", //format: DD month YYYY HH:MM:SS
            timezone: "Pacific/Auckland",
            format: "dd:hh:mm:ss",
            twoDigits: 'on',
            callback: function() { console.log("Event Ended!")     }
    });
});
</script>
    <div class="mycountdownname">
    <div class="countdown-theme">
        <ul>
            <li><p><span><em><b class="days">00</b><i class="daysSlider"><u>00</u><u>00</u></i></em>DAYS</span></p></li>
            <li><p><span><em><b class="hours">00</b><i class="hoursSlider"><u>00</u><u>00</u></i></em>HOURS</span></p></li>
            <li><p><span><em><b class="minutes">00</b><i class="minutesSlider"><u>00</u><u>00</u></i></em>MINS</span></p></li>
            <li><p><span><em><b class="seconds">00</b><i class="secondsSlider"><u>00</u><u>00</u></i></em>SECS</span></p></li>
        </ul>
        <div class="jC-clear"></div><br>
        <div class="jC-clear"></div>
    </div>
    </div>
Answer:2

I am trying to execute a function inside ng-change every time a check box is clicked.I need to get the value of model or somehow know which check box was clicked so that I can call another ...

I am trying to execute a function inside ng-change every time a check box is clicked.I need to get the value of model or somehow know which check box was clicked so that I can call another ...

  1. ng-change inside ng-repeat
  2. checkbox change event inside repeater
  3. ng-change with ng-repeat
  4. ng-change in ng-repeat
  5. ng-change on ng-repeat

http://bluefaqs.com/2016/02/how-to-animate-a-map-location-marker-with-css/ shows a pulsating GPS location blue dot (at the bottom of that page). Does anyone know how such a particular CSS animation ...

http://bluefaqs.com/2016/02/how-to-animate-a-map-location-marker-with-css/ shows a pulsating GPS location blue dot (at the bottom of that page). Does anyone know how such a particular CSS animation ...

  1. animate google marker android
  2. google marker animation
  3. animate marker google maps android
  4. animate marker google maps
  5. animate marker google maps javascript
  6. animate marker google maps swift
  7. animate marker google maps ios
  8. animate marker google maps android github
  9. animate marker on google map with current location

I have a code like this $(".class1 .class2").on('click', function(){ //Do something }); I am trying to somehting like this using variables: var1=".class1"; var2=".class2" $(var1 var2).on('...

I have a code like this $(".class1 .class2").on('click', function(){ //Do something }); I am trying to somehting like this using variables: var1=".class1"; var2=".class2" $(var1 var2).on('...

  1. multiple variables jquery
  2. multiple var jquery
  3. multiple values jquery
  4. append multiple variables jquery
  5. select multiple variables jquery
  6. declare multiple variables jquery
  7. passing multiple variables jquery ajax
  8. return multiple variables jquery
  9. define multiple variables jquery
  10. alert multiple variables jquery
  11. hide multiple variables jquery
  12. multiple selector variables jquery

I am trying to figure out how to pass a transclusion down through nested directives and bind to data in the inner-most directive. Think of it like a list type control where you bind it to a list of ...

I am trying to figure out how to pass a transclusion down through nested directives and bind to data in the inner-most directive. Think of it like a list type control where you bind it to a list of ...