Constructing Javascript Date object using custom date string format e.g. dd/mm/yyyy

The Date object is used to work with dates and times. 
Date objects are created with the Date() constructor.
There are four ways of instantiating a date:

new Date() // current date and time
new Date(milliseconds) //milliseconds since 1970/01/01
new Date(dateString)
new Date(year, month, day, hours, minutes, seconds, milliseconds)

Date(dateString)
This Date constructor only accepts dateString in UTC format.
However, we can write our custom function that accepts a custom format, say dd/mm/yyyy, from which we can extract the date parts and use them to construct a Date object.

function parseDate(input, format) {
  format = format || ‘dd/mm/yyyy’; // somedefault format
  var parts = input.match(/(\d+)/g),
      i = 0, fmt = {};
  // extract date-part indexes from the format
  format.replace(/(yyyy|dd|mm)/g, function(part) { fmt[part] = i++; });
  return new Date(parts[fmt[‘yyyy’]], parts[fmt[‘mm’]]-1,   parts[fmt[‘dd’]]);
}

Usage

parseDate(’01-31-2010′, ‘mm-dd-yyyy’);
parseDate(’31/01/2010′, ‘dd/mm/yyyy’);
parseDate(‘2010/01/31’);

Common mistake in ASP.NET Forms Authentication

We are all used to this now…


    

    

    

    

In ASP.NET Forms authentication, you can allow access to particular users or deny them using the allow and deny tags. Likewise, you can allow or deny access to particular roles.
E.g. to allow access to a page, say Customer, you will do


  

        

             //Allow users in Customers role

         // Deny rest of all users

    

   

Common Mistake is to place 

 before 



This web config below will not allow users even if they are in Customers role


  

        

             // Deny rest of all users

             //Allow users in Customers role