1,105,332 Community Members

getDateFromFormat is not defined

Member Avatar
xuexue
Junior Poster
174 posts since Jul 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi!

This is my code to get the difference of two dates in Javascript.

var today = new Date();

            var dd = today.getDate();

            var mm = today.getMonth()+1; //January is 0!

            var yyyy = today.getFullYear();



            if (dd < 10)

            {

                dd='0'+dd

            } 

            if (mm < 10)

            {

                mm='0'+mm

            } 



            today = mm+'/'+dd+'/'+yyyy;

            var minutes = 1000*60;

            var hours = minutes*60;

            var days = hours*24;


            var foo_date1 = getDateFromFormat(today, "M/d/y");

            var foo_date2 = getDateFromFormat("02/28/2015", "M/d/y");



            var diff_date = Math.round((foo_date2 - foo_date1)/days);

            var ans = Math.abs(diff_date);

            alert(ans);

This works fine in my localhost. However, when I upload it to the server. It does not work anymore.
When I use IE, this is the error it founds.

34288f738c65501d5c6e5c4ca5623554

I tried to chmod the file permissions for all the javascripts and jquery it needs even the folder that these javascript is contained. But it does not do anything.

Kindly help me please :((

Attachments
Member Avatar
xuexue
Junior Poster
174 posts since Jul 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

well, i just changed my code, since it seems that it does not recognize the getDateFromFormat() syntax.

here is the revised one.

var minutes = 1000*60;

    var hours = minutes*60;

    var days = hours*24;

    var date1 = new Date(today);

    var date2 = new Date("02/28/2015");

    var timediff = date2 - date1;

    var ans = Math.floor(timediff / days);
Question Self-Answered as of 10 Months Ago
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: