• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

AAC Znote acc Simple daily count down?

Joriku

Working in the mines, need something?
Joined
Jul 16, 2016
Messages
1,087
Solutions
15
Reaction score
379
Location
Sweden
YouTube
Joriku
Hi,
so I came across something that I have no understanding in. The counter I was looking at counts down in a way I am not familiar with. A counter using numbers longer then ns. (NanoSeconds)
My question is, how do I make something count down everyday to 18.00 then resetting itself instead of the below method?
Example (Server start countdown): Simmple and working countdown for ZNOTE ACC and others ACC (https://otland.net/threads/simmple-and-working-countdown-for-znote-acc-and-others-acc.278681/#post-2677638)

So, this is how it looks like:
(JS attatched)

Lua:
<div class="title">Apocalypse Spawn:</div>
        <div class="info"><script language="JavaScript">
                                                    TargetDateEvent = 1008631786460000
                                                    DateNow = 1631775021000
                                                </script>
        <script language="JavaScript" src="js/countdown_event.js"></script></div>

350a9f31eeb7ef38ec591af2eb5079ad.png
 

Attachments

  • countdown_event.zip
    873 bytes · Views: 4 · VirusTotal
Solution
Alright, after playing around with it a little, I ended up with a failure. Not showing a timer that'll be.

Mmm weird, it worked for me
e8235cc3446a8d9acc2acc244b08c32f.gif
Tested at 18:18


PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>

    <?php
        // date_default_timezone_set('America/Mexico_City');

        $cd_hour = 18;
        $dateFormat = DateTime::createFromFormat('d-m-Y G', (date('G') >= $cd_hour ? (date('d') + 1) : date('d')).'-'.date('m').'-'.date('Y').' '.$cd_hour, new DateTimeZone('GMT-6'));

        $count = '<script language="JavaScript">
            TargetDateEvent = '.($dateFormat->getTimestamp() * 1000).'
            DateNow = '.(time() * 1000).'
            DisplayFormatEvent = "%%H%% hours...
Hi,
so I came across something that I have no understanding in. The counter I was looking at counts down in a way I am not familiar with. A counter using numbers longer then ns. (NanoSeconds)
My question is, how do I make something count down everyday to 18.00 then resetting itself instead of the below method?
Example (Server start countdown): Simmple and working countdown for ZNOTE ACC and others ACC (https://otland.net/threads/simmple-and-working-countdown-for-znote-acc-and-others-acc.278681/#post-2677638)

So, this is how it looks like:
(JS attatched)

Lua:
<div class="title">Apocalypse Spawn:</div>
        <div class="info"><script language="JavaScript">
                                                    TargetDateEvent = 1008631786460000
                                                    DateNow = 1631775021000
                                                </script>
        <script language="JavaScript" src="js/countdown_event.js"></script></div>

350a9f31eeb7ef38ec591af2eb5079ad.png

You can use
PHP:
DateTime::createFromFormat()

PHP:
$cd_hour = 18;
$dateFormat = DateTime::createFromFormat('d-m-Y G', (date('G') >= $cd_hour ? (date('d') + 1) : date('d')).'-'.date('m').'-'.date('Y').' '.$cd_hour, new DateTimeZone('CET'));

And then on your code:
PHP:
TargetDateEvent = ($dateFormat->getTimestamp() * 1000)
DateNow = (time() * 1000)
 
Last edited:
You can use
PHP:
DateTime::createFromFormat()

PHP:
$cd_hour = 18;
$dateFormat = DateTime::createFromFormat('d-m-Y G', (date('G') >= $cd_hour ? (date('d') + 1) : date('d')).'-'.date('m').'-'.date('Y').' '.$cd_hour, new DateTimeZone('CET'));

And then on your code:
PHP:
TargetDateEvent = ($dateFormat->getTimestamp() * 1000)
DateNow = (time() * 1000)
Alright, after playing around with it a little, I ended up with a failure. Not showing a timer that'll be.

Managed to solve it thanks to Alex45, using a more simple method like yours above.
However, this does not work with dual ones. Any change that could help with that?
Lua:
<?php
            $date = 'Jan 1 2045 12:00:00 CET';
            $exp_date = strtotime($date);
            $now = time();

            if ($now < $exp_date) {
            ?>
            <script>
            // Count down milliseconds = server_end - server_now = client_end - client_now
            var server_end = <?php echo $exp_date; ?> * 1000;
            var server_now = <?php echo time(); ?> * 1000;
            var client_now = new Date().getTime();
            var end = server_end - server_now + client_now; // this is the real end time

            var _second = 1000;
            var _minute = _second * 60;
            var _hour = _minute * 60;
            var _day = _hour *24
            var timer;

            function showRemaining()
            {
                var now = new Date();
                var distance = end - now;
                if (distance < 0 ) {
                clearInterval( timer );
                document.getElementById('countdown').innerHTML = 'EXPIRED!';

                return;
                }
                var days = Math.floor(distance / _day);
                var hours = Math.floor( (distance % _day ) / _hour );
                var minutes = Math.floor( (distance % _hour) / _minute );
                var seconds = Math.floor( (distance % _minute) / _second );

                var countdown = document.getElementById('countdown');
                countdown.innerHTML = '';
                    countdown.innerHTML += ' <span style="color:white;">' + hours+ '</span> HOURS';
                    countdown.innerHTML += ' <span style="color:white;">' + minutes+ '</span> MINUTES';
                    countdown.innerHTML += ' <span style="color:white;">' + seconds+ '</span> SECONDS';
                }

                    timer = setInterval(showRemaining, 1000);
                    </script>
                    <span style="color: yellow;" id="countdown">loading...</span>
                    <?php
                    } else {
                    echo 'Hoxera 12.72 Will Start In: <span style="color: yellow;">SERVER STARTED!</span>';
                    }
                    ?>
Post automatically merged:

bump
 
Last edited:
Alright, after playing around with it a little, I ended up with a failure. Not showing a timer that'll be.

Mmm weird, it worked for me
e8235cc3446a8d9acc2acc244b08c32f.gif
Tested at 18:18


PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>

    <?php
        // date_default_timezone_set('America/Mexico_City');

        $cd_hour = 18;
        $dateFormat = DateTime::createFromFormat('d-m-Y G', (date('G') >= $cd_hour ? (date('d') + 1) : date('d')).'-'.date('m').'-'.date('Y').' '.$cd_hour, new DateTimeZone('GMT-6'));

        $count = '<script language="JavaScript">
            TargetDateEvent = '.($dateFormat->getTimestamp() * 1000).'
            DateNow = '.(time() * 1000).'
            DisplayFormatEvent = "%%H%% hours %%M%% min %%S%% secs";
            FinishMessageEvent = "Boss has been spawned.";
        </script><script language="JavaScript" src="layout/js/counter.js"></script>';

      ?>

      <h2>countdown: <?php echo $count; ?> </h2>


<?php include 'layout/overall/footer.php'; ?>

Anyways, ill leave the .js counter im using
EDIT: Remember to correctly setup the timezone(s), in my case GMT-6
 

Attachments

Last edited:
Solution
Mmm weird, it worked to me
View attachment 64601
At the moment i tested it was 18:18


PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>

    <?php
        // date_default_timezone_set('America/Mexico_City');

        $cd_hour = 18;
        $dateFormat = DateTime::createFromFormat('d-m-Y G', (date('G') >= $cd_hour ? (date('d') + 1) : date('d')).'-'.date('m').'-'.date('Y').' '.$cd_hour, new DateTimeZone('GMT-6'));

        $count = '<script language="JavaScript">
            TargetDateEvent = '.($dateFormat->getTimestamp() * 1000).'
            DateNow = '.(time() * 1000).'
            DisplayFormatEvent = "%%H%% hours %%M%% min %%S%% secs";
            FinishMessageEvent = "Boss has been spawned.";
        </script><script language="JavaScript" src="layout/js/counter.js"></script>';

      ?>

      <h2>countdown: <?php echo $count; ?> </h2>


<?php include 'layout/overall/footer.php'; ?>

Anyways, ill leave the .js counter im using
EDIT: Remember to correctly setup the timezone(s), in my case GMT-6
Thank you soo much! <3

Would it be possible to use multiple of them?
 
Last edited:
Would it be possible to use multiple of them?

You will have to make a new counter.js for every countdown and change var names
F.e: DateNow, TargetDateEvent (counter.js) - DateNow2, TargetDateEvent2 (counter2.js)

Here:
 

Attachments

Last edited:
Yes but u have to make a new counter.js for every countdown and change var names
F.e: DateNow, TargetDateEvent (counter.js) - DateNow2, TargetDateEvent2 (counter2.js)

Here:
Alright, I am thinking wrong..
Is anything inside the js script needed to be changed?
Lua:
<?php
        // date_default_timezone_set('America/Mexico_City');

        $cd_hour = 18;
        $dateFormat = DateTime::createFromFormat('d-m-Y G', (date('G') >= $cd_hour ? (date('d') + 1) : date('d')).'-'.date('m').'-'.date('Y').' '.$cd_hour, new DateTimeZone('GMT+1'));

        $count = '<script language="JavaScript">
            TargetDateEvent1 = '.($dateFormat->getTimestamp() * 1000).'
            DateNow = '.(time() * 1000).'
            DisplayFormatEvent = "%%H%% hours %%M%% min %%S%% secs";
            FinishMessageEvent = "Boss has been spawned.";
        </script><script language="JavaScript" src="layout/js/counter1.js"></script>';

      ?>

      <h5>Ghazbaran countdown: <?php echo $count; ?> </h5>
 
Alright, I am thinking wrong..
Is anything inside the js script needed to be changed?

Yes, i attached a file on my previous post so you can based off from there
But here is on pastebin: counter2.js

Code:
PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>

    <?php
        // date_default_timezone_set('America/Mexico_City');

        $cd_hour = 18;
        $dateFormat = DateTime::createFromFormat('d-m-Y G', (date('G') >= $cd_hour ? (date('d') + 1) : date('d')).'-'.date('m').'-'.date('Y').' '.$cd_hour, new DateTimeZone('GMT-6'));

        $count = '<script language="JavaScript">
            TargetDateEvent = '.($dateFormat->getTimestamp() * 1000).'
            DateNow = '.(time() * 1000).'
            DisplayFormatEvent = "%%H%% hours %%M%% min %%S%% secs";
            FinishMessageEvent = "Apocalypse has been spawned..";
        </script><script language="JavaScript" src="layout/js/counter.js"></script>';


        $cd_hour2 = 22;
        $dateFormat2 = DateTime::createFromFormat('d-m-Y G', (date('G') >= $cd_hour2 ? (date('d') + 1) : date('d')).'-'.date('m').'-'.date('Y').' '.$cd_hour2, new DateTimeZone('GMT-6'));

        $count2 = '<script language="JavaScript">
            TargetDateEvent2 = '.($dateFormat2->getTimestamp() * 1000).'
            DateNow2 = '.(time() * 1000).'
            DisplayFormatEvent2 = "%%H%% hours %%M%% min %%S%% secs";
            FinishMessageEvent2 = "Ghazbaran has been spawned.";
        </script><script language="JavaScript" src="layout/js/counter2.js"></script>';


      ?>

      <h2> <?php echo 'countdown1: '.$count; ?> </h2>
      <h2> <?php echo 'countdown2: '.$count2; ?> </h2>


<?php include 'layout/overall/footer.php'; ?>

a3b65c150d43895204e1e35553884fe5.gif

Of course you could make a foreach using an array so you dont copy&paste for every new countdown
However you will still need to make a new .js file for every new one
 
Yes, i attached a file on my previous post so you can based off from there
But here is on pastebin: counter2.js

Code:
PHP:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>

    <?php
        // date_default_timezone_set('America/Mexico_City');

        $cd_hour = 18;
        $dateFormat = DateTime::createFromFormat('d-m-Y G', (date('G') >= $cd_hour ? (date('d') + 1) : date('d')).'-'.date('m').'-'.date('Y').' '.$cd_hour, new DateTimeZone('GMT-6'));

        $count = '<script language="JavaScript">
            TargetDateEvent = '.($dateFormat->getTimestamp() * 1000).'
            DateNow = '.(time() * 1000).'
            DisplayFormatEvent = "%%H%% hours %%M%% min %%S%% secs";
            FinishMessageEvent = "Apocalypse has been spawned..";
        </script><script language="JavaScript" src="layout/js/counter.js"></script>';


        $cd_hour2 = 22;
        $dateFormat2 = DateTime::createFromFormat('d-m-Y G', (date('G') >= $cd_hour2 ? (date('d') + 1) : date('d')).'-'.date('m').'-'.date('Y').' '.$cd_hour2, new DateTimeZone('GMT-6'));

        $count2 = '<script language="JavaScript">
            TargetDateEvent2 = '.($dateFormat2->getTimestamp() * 1000).'
            DateNow2 = '.(time() * 1000).'
            DisplayFormatEvent2 = "%%H%% hours %%M%% min %%S%% secs";
            FinishMessageEvent2 = "Ghazbaran has been spawned.";
        </script><script language="JavaScript" src="layout/js/counter2.js"></script>';


      ?>

      <h2> <?php echo 'countdown1: '.$count; ?> </h2>
      <h2> <?php echo 'countdown2: '.$count2; ?> </h2>


<?php include 'layout/overall/footer.php'; ?>

View attachment 64604

Of course you could make a foreach using an array so you dont copy&paste for every new countdown
However you will still need to make a new .js file for every new one
Alright, back once more..
Re-made everything but the counter 2 is not working.

Could that be due to it being inside footer.php which is not using:?
(Update: Just checked it, result. Only x1 countdown..)
(Update2: Looks like something is taking it's focus onto the same $count)
Lua:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; ?>

<?php include 'layout/overall/footer.php'; ?>

58f00bb09876f3c50582c38c88f55808.png
 
Last edited:
Post the counters and .php file, if you want send me PM
Solved by a nice person

Lua:
<script type="text/javascript">
        function countdown(targets){
            var now = new Date(new Date().toLocaleString("en-US", {timeZone: "Europe/Amsterdam"}));
            for(var i = 0; i < targets.length; i++){
                var target = targets[i]; 
                var hours = now.getHours();

                var hrs = (target - 1) - hours;
                if (hrs < 0){
                    hrs = 24 + hrs;
                }
                var mins = 59 - now.getMinutes();
                if (mins < 0) mins = 0;
                var secs = 59 - now.getSeconds();
                if (secs < 0) secs = 0;
                var str = trim(hrs, 2) + ':' + trim(mins, 2) + ':' + trim(secs, 2);
                document.getElementById('countdown'+(i+1)).innerHTML = str;
            }
        }
        function trim(n, len) {
            var str = n.toString();
            return (new Array((len - str.length + 1)).join('0')) + str;
        }
        var timerRunning = setInterval(countdown, 1000, [12, 18, 7]); /* 12 is 12.00, 18 is 18.00 for ghaz*/
    </script>

<h4><span id="countdown3">Loading..</span></center></h4> -- need more of those
 
Back
Top