Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Datatables date format problem

Posted on 2013-12-10
3
Medium Priority
?
638 Views
Last Modified: 2013-12-10
I'm using datatables with my project and i'm trying to display several dates.

It works fine in Chrome but not in firefox. In firefox the dates are shown as Nan

Any ideas

Here's a link

http://cloud-contractor.co.uk/etest.php
0
Comment
Question by:maddisoncr
3 Comments
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 39708374
Just so you know, in IE 11 it also displays NaN for the dates. NaN stands for "Not a Number".

I don't think this problem is with the date handling code because this:

<html>
<head>
<script>
function getValue()
  {
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth() + 1;
var curr_year = d.getFullYear();
var newdate= (curr_date + "/" + curr_month + "/" + curr_year);
alert(newdate);
}
</script>
</head>
<body>

<h1 id="myHeader" onclick="getValue()">Click me!</h1>

</body>
</html>

Open in new window


This works just fine in FF and IE 11.

Hope this helps.
0
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39708392
replace :
							var d = new Date (data);
						
							var curr_date = d.getDate();
							var curr_month = d.getMonth() + 1;
							var curr_year = d.getFullYear();

							var newdate= (curr_date + "/" + curr_month + "/" + curr_year);
										
							if( (data)){
								return newdate;
							}
							else
							{
							return "";	
							}

Open in new window

by :
							if(data) {
								var d = data.split(/-|\s/);
							
								var curr_date = d[2];
								var curr_month = d[1];
								var curr_year = d[0];

								return curr_date + "/" + curr_month + "/" + curr_year;
							}
							else
							{
								return "";	
							}

Open in new window

0
 

Author Comment

by:maddisoncr
ID: 39708533
thank you guys for the quick responses :-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question