PHP style date and time formatting for ASP
I donâ€™t often work in VBScript for ASP anymore as I find PHP to be approximately 100 times more robust. One area where this is immediately apparent is the difference between date formatting options between the two languages. While PHP has its date() function that can format a date in almost any form imaginable, VBScriptâ€™s FormatDateTime() is limited to a few constants that I find to be too much or too little information in almost every case where I need it. So to make up for the lack of formatting support I wrote a date()-like function to use in ASP.
It supports about 98% of the formatting options that date does, with anything timezone related being the bulk of whatâ€™s missing (since there is NO way to get the servers timezone information via VBScript). Feel free to copy, modify and redistribute as long as you remember to give fair credit. Speaking of which, every bit of this function was hand-written by me except for the Unix timestamp formatting piece which I found at ilovejackdaniels.com and decided to use because it was right there in front of me.
You can view or download the code as a text file.
* This post was originally published on December 15, 2005 at http://www.csb7.com/whyblogwhy/index.php/2005/12/15/php-date-style-formatting-for-asp/
This site uses Akismet to reduce spam. Learn how your comment data is processed.