0

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");
Community
  • 1
  • 1
sherly
  • 305
  • 1
  • 7
  • 18
  • `Ext undefined` means that the extjs code is not loaded by the time you're calling that line. Can you fiddle it so we can gain more insights? Also shouldn't your date pattern be `d-m-Y` instead? – Val May 28 '15 at 03:24
  • @Val, okay I'll fiddle it and the pattern, thank you for pointing out.After changing, it says, Cannot read property 'format' of undefined – sherly May 28 '15 at 03:32
  • Yes, same error nonetheless but the pattern was wrong anyway and you'd have discovered that next. – Val May 28 '15 at 03:34
  • http://jsfiddle.net/chdxmg8d/ – sherly May 28 '15 at 03:35
  • You need to fiddle at least your HTML page and the relevant part of your JS code so we can see why ExtJS is not being loaded properly – Val May 28 '15 at 03:36
  • I'm not sure how to include the google reference to ext files... – sherly May 28 '15 at 03:37
  • http://jsfiddle.net/chdxmg8d/1/ – sherly May 28 '15 at 03:39

1 Answers1

1

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.

Val
  • 207,596
  • 13
  • 358
  • 360