WCF Javascript Date Helper Class

I got tired of dealing with this issue, and I didn’t want to use any third party libraries so I wrote a quick little helper class to help you deal with this date formatting issue.

This “formatJSONDateLocal” method will convert from UTC Time to the clients local time.  This is very handy when working with services storing time as UTC.  If I improve it I will update this post.

You can modify the formatJSONDateLocal to get the format you are looking for.


var ViviScapeWCFDateHelper = {

formatJSONDate: function (jsondate) {
var sdate = new Date(parseInt(jsondate.substr(6)));
var formattedsdate = sdate.getFullYear() + "-" + ("0" + (sdate.getMonth() + 1)).slice(-2) + "-" + ("0" + sdate.getDate()).slice(-2);

return formattedsdate;
formatJSONDateLocal: function (jsondate) {
var odate = new Date(parseInt(jsondate.substr(6)));
var today= new Date();
var offset = today.getTime() + (today.getTimezoneOffset() * 60000);
var sdate = new Date(odate + (3600000 * offset));

var realhour = (sdate.getHours() > 12) ? sdate.getHours() - 12 : sdate.getHours();
var ampm = (sdate.getHours() >= 12) ? "PM" : "AM";
var formattedsdate = sdate.getFullYear() + "-" + ("0" + (sdate.getMonth() + 1)).slice(-2) + "-" + ("0" + sdate.getDate()).slice(-2) + " " + realhour + ":" + sdate.getMinutes() + ampm;

return formattedsdate;


This is how you use it:

//Convert WCF JSON DATE to Date

//Convert WCF JSON UTC DateTime to local datetime

Posted in .NET WCF Services, HTML5, Integration, JavaScript, jQuery | Leave a comment

JavaScript WCF Date Formats

Here is a little cheat sheet to help you see the output of the function used when parsing a WCF JSON Formatted Response.

#”result” is the return object from the web service.

var sdate = new Date(parseInt(result.mydate.substr(6)));

#You can handle formatting the response with any of function below.

parsedDate: Tue Jun 17 2014 14:15:45 GMT-0400 (Eastern Daylight Time)
sdate.getDay(): 2
sdate.getDate(): 17
sdate.getFullYear(): 2014
sdate.getHours(): 14
sdate.getMilliseconds(): 777
sdate.getMinutes(): 15
sdate.getMonth(): 5
sdate.getSeconds(): 45
sdate.getTimezoneOffset(): 240
sdate.getUTCDate(): 17
sdate.getUTCDay(): 2
sdate.getUTCFullYear(): 2014
sdate.getUTCHours(): 18
sdate.getUTCMilliseconds(): 777
sdate.getUTCMinutes(): 15
sdate.getUTCMonth(): 5
sdate.getUTCSeconds(): 45
sdate.getYear(): 114

Hope this was useful, Enjoy!

Find out how to handle WCF JSON Date Response with HTML5


Posted in JavaScript, jQuery | Leave a comment

WCF JSON Date Format to Javascript Nightmare

I wanted to share this little snippet that has saved my life many of time.  Those of you that run into this will appreciate this short line of javascript code that will make your dreams come true.

I am using the JQuery library for the service call, then handling the results with a little magic.

*Not your can handle the formatting on your service side, but If you don’t have access to the service this is an alternative method to accomplish the job.

Code Begin:


url: yourservicesaddress.svc/test,

data: {testid: _mytestid}//variables



var sdate = new Date(parseInt(result.mydatefield.substr(6)))
var formattedsdate = sdate.getFullYear() + “-” + (“0” + (sdate.getMonth() + 1)).slice(-2) + “-” + (“0” + sdate.getDate()).slice(-2);

//Then here you can use formatted date in a HTML 5 Date formatted text box.  Pretty //simple.



If you want to know about how you can integrate services check us out at ViviScape.  We provide custom software engineering solutions to make your life easier.




Posted in .NET WCF Services, HTML5, jQuery | Tagged | 1 Comment

jQuery Include Example

This is an example of something that  jQuery developers commonly used.  I wanted to share this for people new to jQuery.  It may be able to save them time, and may allow them to accomplish incredible things.

I have listed the download the project files below:


Posted in jQuery, Web Design | Leave a comment

Google Maps V3 Example With Custom Marker Points

For all of you code monkeys, or people just wanting to integrate a little Googlization to your site.

I created utilizing the Google Maps V3 API, on your website or mobile solution. This demonstration is looking up the longitude and latitudes based on address to identify points within Google maps, then observing the points to evaluate the appropriate zoom level of the map. I have expanded it to create custom “Info Windows”. This example uses the jQuery library along with a custom JSON array as its data source.

If your interested on you can expand this example using routing functionality such as finding direction and so forth  let me know.

For those interested I will expand within this thread.

If you have any question’s let me know.  You can find me at http://www.linkedin.com/in/arthicks.

Example of the map and the code:




Posted in Google, jQuery | Leave a comment

Simple Problems Simple Solutions

Have you been faced with problems that seem to be way to complicated to deal with?  Common Sense tells us that simple problems have simple solutions.  I know your saying, “Art, speak for yourself.  You don’t know what I am going through”.  This is true, but you have already thought about different solutions to your problems.

You have the answer, but you choose to not do it.  There are reasons for this action not occurring, most them  are it is mentally to hard,  emotionally your scared, or you believe that is going to affect someone else.  All of these being natural human feelings.  If only life had a preview button to see what the outcome would be, before we acted on these easy solutions.

One step towards solving the problem, if you are having troubles dealing with the correct answer, is to write down all the answers without putting extra thought into it.  Then come back and write all of the consequences behind executing your solution.  If then choose the one that will solve the problem with least amount of impact.  Remember stress or skepticism is our perception of events that we encounter.  Don’t let your fears or lack of knowledge help you solve simple problems.

Posted in Uncategorized | Tagged , , | Leave a comment

No Time to Think

Many of us face the challenge of “not having enough hours in a day”.  There is a simple common sense solution to all of your problems.  Don’t choose to take on battles you can not when in a few hours.   Use a similar strategy to the snow ball effect.  Small victories will result in tide changes towards winning the war.  

  1. Start with sitting down, writing or typing out what you need to accomplish.
  2. Start attacking the tasks that you complete in the shortest amount of time.
  3. Notify parties where you need more information for the tasks where you may need more clarification.  Don’t start a project where you don’t know completely what the heck your doing.  You’ll end up wasting a ton of time.  Plus this put the ball back in their court.  Try not to have people waiting you.  All eyes can’t be on you if it isn’t your turn to dance.
  4. Break your large tasks into phases or micro tasks.  By doing this you can move back to step 2 and do it again.

Pretty quick simple way of looking at juggling a crazy load of things to do.  

I am open to any other strategies that you have come up with to handle your crazy work load.

Posted in Uncategorized | Tagged , , , , | Leave a comment