convert integer to date forma YYYY-MM-DD

convert integer to date forma YYYY-MM-DD

arcanisgkarcanisgk Posts: 41Questions: 12Answers: 0

hello guys i wanna Foced cell date to format YYYY-MM-DD

i am exportin it with:

$('row c', sheet).each(function () {

                            

                            var value = $('is t', this).text() || $('v', this).text();
                            var count = (value.match(/\n/g) || []).length;
                            
                            var isdate = (new Date(value) !== "Invalid Date") && !isNaN(new Date(value))?true:false;
                            console.log(value); //i get 43742
                            console.log(this);
                            console.log(isdate);
                            

                            if(isDate){
                                $(this).attr('s', 49);
                            }else{
                                if (count == 0) {
                                    $(this).attr('s', styleIndex - 2);
                                } else {
                                    $(this).attr('s', '55');
                                }
                            }
                        });
                        $('row:first c', sheet).attr('s', '32');

need convert 43742 to 2019-10-04 and i think rebuild the node for cell date

Answers

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    Might be simpler to use orthogonal data to format the output for the export. See this example. You can use moment.js to format the date output.

    Kevin

  • arcanisgkarcanisgk Posts: 41Questions: 12Answers: 0
    edited October 2021

    sorry i have review the doc you give me; but i don't understand how to implement it. i am working with HTML markup content not ajax.

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974
    edited October 2021

    Do you have specific questions about the docs?

    The data source doesn't matter, you can still use orthogonal data like the example. You can build a test case showing an example of what you have and we can update the example to show how to use orthogonal data.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

Sign In or Register to comment.