PDA

View Full Version : var dt = new Date();



Plkilroy
19 Jul 2011, 9:34 PM
Hi, I need some help adding date to App using; var dt = new Date(); any ideas, thanks -P

{
xtype: "container",
width: 280,
dock: 'right',
html: 'date'
},

Plkilroy
20 Jul 2011, 7:16 PM
Ive asked this question three times now, and still no one knows how to display todays date. This is the most basic stuff in JS.

The lack of support unfortunately lets Sencha down

emm
20 Jul 2011, 8:18 PM
I don't get it.
Can you explain more precisely what you are trying to do?
How is the code below your post linked to your request?
(NB/ you should use the sharp icon in the toolbar when writing code into a post)

Happy sencha time!
emm

Plkilroy
20 Jul 2011, 8:53 PM
Hi Emm, thanks for your post, simply I want to show todays date in the docked right container, currently the html displays the word date. I would like to use var dt = new Date(); and pass this value to html instead.

I have tried all sorts but no good, and need some help, thanks -P


{
xtype: 'toolbar',
ui: 'none',
height: 20,
style: 'background-color: white;',
items: [{
xtype: "container",
width: 280,
height: 20,
html: 'About Us',
dock: 'left'
},
{
xtype: "spacer"
},
{
xtype: "container",
width: 280,
dock: 'right',
html: 'date'
},
]
}

emm
20 Jul 2011, 8:58 PM
Look at the Sencha Touch Documentation.
You have a class called Date.
You made it right using

var dt = new Date();

But you miss a formatter to display it:

dt.format('Y-m-d')

You can use this to test the code above:

document.write(dt.format('Y-m-d'));

Plkilroy
20 Jul 2011, 9:08 PM
Hi Emm, that was what I have been trying to implement. I cant get document write var dt let alone pass it to html, if you know how would be great!!! -P

emm
20 Jul 2011, 9:17 PM
Try this:

var panel = (your panel...);
var dt = new Date();
panel.update(dt.format('Y-m-d'));

Plkilroy
21 Jul 2011, 1:07 AM
Thanks again, I have been playing around before posting back, still not there, this is what I have, but cant add the myPanel.update(dt.format('Y-m-d'));


onReady: function () {

var dt = new Date();

var myPanel = new Ext.Panel({
id: "myPanel",
fullscreen: true,
items: [
{

}
]
});
}

emm
21 Jul 2011, 1:15 AM
Dear Pikilroy,
Try to learn with the sencha examples, that will help you a lot!
In the mean time, just add that to your first example:


{
xtype: "container",
width: 280,
dock: 'right',
html: new Date().format('Y-m-d')
},

Plkilroy
21 Jul 2011, 3:30 AM
A really big thanks for your help! And yes I have been on a learning curve re Sencha, I couldn't find any documentation on implementing the date class.

I hope this will help some others! and thanks again -P

emm
21 Jul 2011, 4:19 AM
You're welcome