Search code examples
javascriptsvnextjsextjs4

Ext.Date.format doesn't work


I refered to

How to convert timestamp to customized date format in ExtJS4.1 model?

Why does Date.parse give incorrect results?

The error shown in console is Ext undefined.

So I included this in footer :

<script type="text/javascript" src="http://extjs-public.googlecode.com/svn/tags/ext-2.2/release/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="http://extjs-public.googlecode.com/svn/tags/ext-2.2/release/ext-all.js"></script>

Now error:

Uncaught TypeError: Cannot read property 'format' of undefined

All I'm trying to do is,

my date string format : 2015-05-15 00:02:50

I want this format:

15 May 2015

My line of code with above mentioned errors:

data[i].postDate = Ext.Date.format(new Date(data[i].postDate), "d-m-Y");

Solution

  • I've updated your fiddle and since you're using ExtJS 2.2 there is no Ext.Date but you can get around the problem by using Ext.util.Format.date

    var mydate="2015-05-15 00:02:50";
    mydate = Ext.util.Format.date(new Date(mydate), "d-m-Y");
    

    This will work.