Click here to Skip to main content
15,888,301 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello people, im new here. I want to create simple event system using PHP lang, but im stuck a little. First, i need that counter for example: when visitor open event, on right side i put event start in xx:xx:xx. So time of begining event is stored into database. I have generate a little bit simple counter but i have a little problem in this code. I will post my code so i hope you will help me to resolve that.

What I have tried:

<div class="box-widget counter-widget gradient-bg" data-countDate="06/02/2020">
<div class="countdown fl-wrap">
<div class="countdown-item">
<span class="days rot">00</span>
<p>days</p>
</div>
<div class="countdown-item">
<span class="hours rot">05</span>
<p>hours</p>
</div>
<div class="countdown-item no-dec">
<span class="minutes rot2">46</span>
<p>minutes</p>
</div>
<div class="countdown-item-seconds">
<span class="seconds rot2">00</span>
</div>
</div>
</div>


Javascript code is:

if ($(".counter-widget").length > 0) {
    var countCurrent = $(".counter-widget").attr("data-countDate");
    $(".countdown").downCount({
        date: countCurrent ,
        offset: 0
    });
}


Problem is when i get time from database, and that events starts in 8h and 25min i get 116 days. And that is problem 116 days. I don't get where is my mistake.
06/02/2020
date is good. But they display me 116 days. Why?

Thanks all.
Posted
Updated 6-Feb-20 4:46am

1 solution

Sounds like a localization issue - your code is treating 06/02/2020 as 2nd June, not 6th February.

How you fix that will depend on how your downCount method is parsing the date. You could try using the unambiguous date format: 2020-02-06
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900