CFJS 1.1.12

This release contains a small change to the DateFormat() function.

Previously, the CFJS version of DateFormat() required a JavaScript date object to be passed in as it's first argument. Now, however the user can pass in a string representation of a date and the function will attempt to convert this to a Date object for processing.

The following snippets work just fine:

var my = {};
my.date = "Sep 12 1975";
my.date_formatted = $.DateFormat(my.date,"mm/dd/yyyy");
document.write(my.date_formatted)
var my = {};
my.date = "9/12/1975";
my.date_formatted = $.DateFormat(my.date,"mm/dd/yyyy");
document.write(my.date_formatted)
Let's include the time in this example... yep still works
var my = {};
my.date = "November, 23 1975 11:45 PM";
my.date_formatted = $.DateFormat(my.date,"mm/dd/yyyy hh:MM:ss TT");
document.write(my.date_formatted)

So this also would work

var my = {};
my.date_formatted = $.DateFormat("September, 12 1975","mm/dd/yyyy");
document.write(my.date_formatted)

The following code snippet does NOT work:

var my = {};
my.date = "09-12-1975";
my.date_formatted = $.DateFormat(my.date,"mm/dd/yyyy hh:MM:ss TT");
document.write(my.date_formatted)

JavaScript doesn't recognize the dash as a date separator (apparently) in order to convert the string to a date.

Anyway, I hope this little addition to the DateFormat function makes it more useful to folks. I know it did for me, since I'm the one who needed the change in the first place! :o)

TweetBacks
Comments
Kevin Parker's Gravatar Chris, I just found CFJS, and I'm very intrigued! I have been working with YUI and was looking at writing a "CF friendly" facade for it, but I began realizing the size of that task, and that some of what I want still isn't available in YUI. I'll let you know my experience once I've tried jQuery and your facade script. Thanks!
# Posted By Kevin Parker | 11/13/09 5:56 PM
Chris Jordan's Gravatar Hey Kevin! Thanks for the comment. I hope you find CFJS as useful as I do. Keep in mind that while it is a jQuery plug-in there is also a non-jQuery plug-in version available.


So, instead of:
$.ArrayLen(myArray); // the jQuery way...

you could use:
CFJS.ArrayLen(myArray); // the non-jQuery way...

Just get the non-jQuery branch from SVN if that's what you'd prefer. Either way, I hope you find it useful! :o)

(Hey, I just checked out your site and noticed that you're in Ft. Worth. Cool. I'm in the DFW area too!) :o)
# Posted By Chris Jordan | 11/13/09 6:04 PM
James Moberg's Gravatar Any plans to add support for the DateAdd() function?
# Posted By James Moberg | 3/10/10 8:30 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.4.001. Contact Blog Owner