Formatting Javascript Date with Month Name

February 16, 2015

Oh the limitations of javascript… So I needed a way to produce a date/time string that would match the way I format my date/time strings in C# (MMMM dd, yyyy hh:mm:ss tt). As most know, javascript isn’t very nice when it comes to working with dates/times. My project had the added benefit of some special requirements. jQuery could be used, but no plug-ins are allowed.

After doing plenty of searching and posing a question on StackOverflow, I came up with this function. I sure wish the function could be shorter…

function getFormattedDateTime(dateTimeToFormat) {
dateTimeToFormat = new Date(dateTimeToFormat);

var zeroPad = function (val) {
return (val <= 9 ? '0' + val : '' + val);

var month = dateTimeToFormat.toLocaleString('en-us', {month: "long"});
var day = dateTimeToFormat.getDate();
var year = dateTimeToFormat.getFullYear();

var hour = ((dateTimeToFormat.getHours() + 11) % 12 + 1);
var minutes = dateTimeToFormat.getMinutes();
var seconds = dateTimeToFormat.getSeconds();
var suffix = (hour <= 12) ? 'AM' : 'PM';

return month + ' ' + zeroPad(day) + ', ' + year + ' ' + zeroPad(hour) + ':' + zeroPad(minutes) + ':' + zeroPad(seconds) + ' ' + suffix;

You can play with this function in action on JSFiddle


Enable app.debug.config app.release.config

September 15, 2014

Excellent post on how to transform App.config.

build. measure. learn.

For now only web.config supports transformation (web projects).
This transformations allow you can have different settings for different configurations (debug or release). A good example is transformation of a connection string. Probably you will have a different connection string when you release the app in production.

Doing the following steps you can obtain transformation on a app.config too.

1. Prepare your project and add app.config, app.debug.config and app.release.config. Make sure is running under .Net 4.0 .

2. Right click on the project, click Unload project and then Edit .csproj.

3. Below the last PropertyGroup add the following:

4. Modify the section ItemGroup that’s related to app.config/app.*.config files

5.Below the last Import tag insert this one

6.Right before end of Project tag add this

7.Now you can save the project, right click the project and choose Reload Project.

8.For app.debug.config / app.release.config files you can use the template that’s…

View original post 15 more words