Chapter 14.8.1. Working with Dates and Times

JavaScript has a handy Date object for keeping track of dates and times. Unfortunately, however, when you make an Ajax request to a server, that server isn’t going to understand that Date object (even if you could find a way to directly send it!). And you’re not going to get a JavaScript date back from the server. MochiKit.DateTime provides a set of functions for converting dates between JavaScript and the rest of the world.

To get a JavaScript Date object, use one of the following functions:

  • americanDate(str) MM/DD/YYYY

  • isoDate(str) ISO 8601 date (YYYY-MM-DD)

  • isoTimestamp(str) ISO 8601 timestamp (YYYY-MM-DD hh:mm:ss or YYYY-MM-DDThh:mm:ssZ)

To convert a JavaScript Date object for use externally, ...

Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.