HOWTO: 2 digit month from a date using NumberFormat() in ColdFusion

From the blog:

Dan Vega: 2 digit month from a date using NumberFormat()

I ran across a small problem today with regards to a dates month. You may come across this problem in a different context but I have a quick and easy solution for all occasions. In a shopping cart application the processor I am using (Payflow Pro) needs a 2 digit month for the expiration date. This means that for the month of march we need to represent it as 03 and not just 3. So whats the problem? Even when you format the date we drop leading zero’s. If you run the following you code we can see what the output is:

{ts ‘2007-03-12 19:54:43’} 3

So how can we fix this? That is where a great utility method…

Advertisements

~ by WPA Staff on June 25, 2012.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: