Date format on a cell

Tags: #<Tag:0x00007efc62355b28>

I have a cell which displays Date in the format MM/DD/YYYY, I use DatePipe and display using below
code:
datepipe.transform(new Date(), ‘MM/dd/yyyy’);
It displays the current date, say 06/10/2020
But when I send this value to backend , I actually want to save along with time, i.e; hh:mm:ss

I was trying to see if there is a pattern that we can set, while defining the columns which actually displays date only , but actual value is date and time

{ data: ‘currDate’, type: ‘text’, renderer: this.datarenderer, readOnly: true, }

Hi @krish

I see you use a custom renderer renderer: this.datarenderer.
Can you show your implementation?
It could be easier to find a solution.

Nevertheless, I think you have to use with type: 'date' not with type: ‘text’,.

Hi,
Yes I actually used type ‘date’, it was a typo here.
Here is the implementation:
afterSetDataAtCell(event) {
this.tableInstance.setDataAtCell(e[0], 2, this.mydatePipe.transform(new Date(), ‘MM/dd/yyyy hh:mm:ss a’))
}

columns= [
{ data: ‘currDate’, type: ‘date’, dateFormat: ‘DD MMM YYYY’} ]

In the renderer, there is no much logic, its just changing the background color of cell.

We have two separate renderers - one to render date and the second to render time.

Here is a link to customer renderers - https://handsontable.com/docs/7.4.2/demo-custom-renderers.html
And here is a custom editor - https://handsontable.com/docs/7.4.2/tutorial-cell-editor.html

So you have to write your own editor to put both together.

You can choose one of them as a base to the other. For instance, you could start with class DateAndTimeEditor extends DateEditor.