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

  • SEARCH
  • Home
  • 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 8960563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:41:12+00:00 2026-06-15T15:41:12+00:00

i am sending the date as string from server as explained below which has

  • 0

i am sending the date as string from server as explained below which has both date and time part like 2010-12-07 17:35:04.127.
what i want is just display the date not the time part in data table column i.e 2010-12-07. But also i want the sorting happens
on complete date including the time part. So customer created at 2010-12-07 18:35:04.12 should be displayed above
2010-12-07 17:35:04.12 in dataTable column. here is my specific date column code snippet in datatable

  "aoColumns": [ { "mDataProp": "customerCreated","bSearchable": false,
                           "fnRender": function ( o, val  ) 
                               {
                               var javascriptDate = new Date(o.aData["customerCreated"]);
                               javascriptDate = javascriptDate.getFullYear()+"/"+javascriptDate.getMonth()+"/"+javascriptDate.getDate();
                               return "<div class= date>"+javascriptDate+"<div>";
                               }

                       } ]

Issues i am facing are:-

1)On IE and Mozilla date is displayed as NaN/NaN/NaN. Not getting why?

2)On Chrome date is displayed but month is displayed decremented by 1.Why javascriptDate.getMonth() return month decremented by 1?

3)i am not sure sorting will work if take above route where i am displaying just date part but want sorting to happen on complete date including date part?

FYI
i am using the bserverSide as false .Basically i am getting the data from server in one go and do the sorting on client side?

  • 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-15T15:41:13+00:00Added an answer on June 15, 2026 at 3:41 pm

    JS months start with 0 and the date needs / instead of –

    Related to Problem with date formats in JavaScript with different browsers

    Try this DEMO

    function getFormattedDate(dString) {
      var d = new Date(dString.split(".")[0].replace(/-/g,"/")); // assuming 2010-12-07 17:35:04.127
      var mm = d.getMonth()+1;
      var dd = d.getDate();
      if (mm<10)mm="0"+mm;
      if (dd<10)dd="0"+dd;
      return d.getFullYear()+"/"+mm+"/"+dd;
    }
    
    "aoColumns": [ { "mDataProp": "customerCreated","bSearchable": false,
      "fnRender": function ( o, val  ) {
        return "<div class= date>"+getFormattedDate(o.aData["customerCreated"])+"<div>";
      }
    } ]
    

    If you need the time too it would be

    function getFormattedDate(dString) {
      var d = new Date(dString.split(".")[0].replace(/-/g,"/")); // assuming 2010-12-07 17:35:04.127
      var mm = d.getMonth()+1;
      var dd = d.getDate();
      if (mm<10)mm="0"+mm;
      if (dd<10)dd="0"+dd;
      var hh = d.getHours();
      var min = d.getMinutes();
      if (hh<10) hh="0"+hh;
      if (min<10) min="0"+min;
      return d.getFullYear()+"/"+mm+"/"+dd+" "+hh+":"+min;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I sending ajax request from a jQuery file like below, which expects response in
I'm sending some dates from server that has it's time in gmt-6 format, but
I am sending in a strings in with the date part, hour part and
How can i make conditions on sending emails to users based on date which
Sending XML from C# Server and receiving it it in Android Java client This
A client is sending a string containing a date in format YYYYMMDDHHmmSS (e.g. 201004224432
I'm having a problem sending java.util.Date objects over RMI, to and from machines in
13-11-2012 09:14:39 is the sample timestamp string getting from server in my app. I
I have a date picker sending string dates in Euro format, e.g. 02/12/2011 (December
For sending HTML document information such as content-encoding , charset , date , last-modified

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.