Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8262275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:42:28+00:00 2026-06-08T03:42:28+00:00

I need to create a countdown script that reads the due date from an

  • 0

I need to create a countdown script that reads the due date from an XML file,

The XML FILE:

<?xml version="1.0" ?>
<Imskia ID="Ramadan2012">
<day date="2012, 7 - 1, 23">
    <Fagr>3:26</Fagr>
    <Shrok>5:22</Shrok>
    <Dohr>12:02</Dohr>
    <Asr>3:38</Asr>
    <Maghrb>6:57</Maghrb>
    <Ishaa>8:27</Ishaa>
</day>
<day date="2012, 7 - 1, 24">
    <Fagr>3:26</Fagr>
    <Shrok>5:22</Shrok>
    <Dohr>12:02</Dohr>
    <Asr>3:38</Asr>
    <Maghrb>6:59</Maghrb>
    <Ishaa>8:27</Ishaa>
</day>  
</Imskia>

and here the Javascipt in the HTML file:

$(document).ready(function(){
    $.get('test.xml', function(d){
    $(d).find('day').each(function(){

        var $day = $(this); 
        var date = $day.attr("date");
        var Maghrb = $day.find('Maghrb').text();

        $('body').append($(html));

    //countdown 
    $('#defaultCountdown').countdown({ 
        until: new Date(date), timezone: +2
    });             

    });
});


});

the problem was that the countdown script doesn’t read the variable stores the Date from the XML file, but it works fine when put it manually as below:

    //countdown 
    $('#defaultCountdown').countdown({ 
        until: new Date(2012, 7 - 1, 24), timezone: +2
    });     
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:42:29+00:00Added an answer on June 8, 2026 at 3:42 am

    When you do

    var date = $day.attr("date");
    

    date holds a string literal ("2012, 7 - 1, 23" for the first case). What you need to do is to somehow convert this string literal into a JavaScript Date object. If you can do without the subtraction in the month component (i.e., keep your date string as "2012, 6, 23", then the simplest way to get the date would be

    // split along the commas to get an array
    var dateComponents = $day.attr("date").split(', '); 
    var date = new Date(dateComponents[0], dateComponents[1], dateComponents[2]);
    

    Note that the second argument to new Date() (the month component) is 0-indexed so January is 0 and December is 11.

    And you can change the countdown to

    $('#defaultCountdown').countdown({ 
        until: date, timezone: +2
    });             
    

    However, if changing the format of the date isn’t an option, eval should help you convert the subtraction string to its actual value. In this case, the code would be

    // split along the commas to get an array
    var dateComponents = $day.attr("date").split(', ');
    var date = new Date(dateComponents[0], eval(dateComponents[1]), dateComponents[2]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day to all. I need to create a graphical countdown in js. The
I need to create a countdown clock, that counts down the days, hours, minutes
I want add new user from another script and I need create password for
I need to create a script that will log into an authenticated page and
I need to create a Timer that counts down from a string I get
How create a link_to_remote in a jQuery script where url need a parameter that
I need create some fork for project. So for some beans that depends from
I'm using Visual Studio 2008 and I need create a DataTable from a Excel
The image posted below is taken from a word document. I need create a
I am trying to create a countdown using javascript. I got some code from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.