VBScript and VB6 native Date functions emulated in Javascript


As a scripting language, Javascript (aka ECMAScript, aka JScript) is extremely powerful, but quite weak with date/time manipulation.  Several types of date/time operations are very difficult to accomplish (and accurately) in Javascript.  VBScript is comparatively very strong in that area, though, with several intrinsic date/time-related functions, like IsDate, CDate, DateAdd, DateDiff, DatePart, MonthName, WeekdayName, and FormatDateTime.  Better yet is VB6's Format function. 

Anyway, after banging my head on the wall for the nth time, I decided to try to re-create those functions in a Javascript include file, called jsDate.  Try it out...

Live Demo (element relationships: related,  active )

1) pick Parameters:

2) call a Function:

3) and get this Result:

Source (right-click and save)

jsDate.js, jsDate.html (this page), jsDate_demo.js (this page's "glue" script)




As-is, etc.  If you ask nicely, I may provide support via email.


-Rob (@slingfive) Eberhardt, Slingshot Solutions
Use freely, but be honest about it.  I just ask for credit.  Feedback and contributions are welcome and desired.