O'Reilly logo

Ext JS 4 Web Application Development Cookbook by Stuart Ashworth, Andrew Duncan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Parsing, formatting, and manipulating dates

Dates crop up in every application in some form or another. Ext JS 4 provides a useful Ext.Date class that enhances the JavaScript Date object's functionality with a series of useful methods to help when working with dates.

Note

If you already have experience with PHP, you will be pleased to know that the formatting syntax for Ext.Date is a (comprehensive) subset of those available in PHP's date function.

How to do it...

  1. Start by instantiating the Date object, passing in numbers to represent the year, month, day, hour, and minute:
    var date = new Date(2011, 6, 6, 22, 30);
  2. Add the following date/time patterns for formatting dates:
    Ext.Date.patterns = { ISO8601Long: "Y-m-d H:i:sP", ISO8601Short: "Y-m-d", ShortDate: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required