Hello,
What's the best way to add the current date to a record field?
Here's is what was my initial guess:
Code:
Ext.define('Message', {
extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'id', type: 'int' },
{ name: 'title', type: 'string' },
{ name: 'body', type: 'string' },
{ name: 'created-at', type: 'date', dateFormat: 'Y-m-d H:i:s', defaultValue: new Date() }
]
}
});
However, "new Date()" picks the date when the Model class is instantiated. I would it to pick the date when I do a Ext.create('Message').
I know I could just do:
Code:
Ext.create('Message', { 'created-at': new Date() })
But I was searching for a way to make sencha do this automatically.
Thanks