title: How to handle DateTime object in an Ajax Return Object?
body: <p>I have a situation which keeps coming up all the time when I think it's over. It's a ASP.NET project but I am not using ASP.NET AJAX elemets and any server side elements in design part. I am using ASP.NET to handle database operations and using jQuery elements in design, also using only jQuery AJAX to send and receive data from UI.</p>
  
  <p>I have a method which runs when an ajax call is made and returns an object class with a DateTime element in it. I need to use what returns in a javascript function to show on the screen. I don't want to use JSON.NET or anything else to serialize the returning class beacuse ASP.NET does all the conversions when I return an object class, itself already.</p>
  
  <p>So, my problem is I am getting a long date format which is not compatible with any javascript function and none of moment.js or date.js libraries supporting that format. The output of the datetime asp.net object in javascript is like:</p>
  
  <p>"Sun Aug 11 2013 00:00:00 GMT +0300 (Turkey Daylight Time)"</p>
  
  <p>I looked for some info about that for days and didn't find any questions or articles explaining how to cast returning datetime properly. May be not looking for the right thing...</p>
  
  <p>I know that I can create a JSON string and send that class' values with it. I've been there. But my head starts hurting when I start to question <strong>the logic of asp.net automatically serializing returning classes and returning a non useful datetime object</strong>.</p>
  
  <p>So, I decided to hear your opinions on that matter. What is the best way of dealing datetime conversion issues in asp.net?</p>
  
  <ol>
  <li>I can change the DateTime object to a simple string and get the value as string and cast it to datetime in asp.net and return the same class with a string like a date object, but that is creating other casting problems in javascript side (DD/MM/YYYY and MM/DD/YYYY issues).</li>
  <li>I can look for a way to properly cast the returning datetime format of asp.net to javascript form (which I believe is after a lot of research is quite impossible)</li>
  <li>I can create my class which would include a long int object and cast (serialize) that datetime object to JSON format before sending as a return call in asp.net method.</li>
  </ol>
  
  <p>Which one of these is better and why, and is there another, better way to do this?</p>
  
  <p>Thanks...</p>