0

There is date type field, for example:

{
    label: 'Created at',
    field: 'creationDateF',
    type: 'date',
    inputFormat: 'DD-MM-YYYY HH:mm:ss', //e.g. 07-09-2017 19:16:25
    outputFormat: 'DD-MM-YYYY HH:mm:ss'
}

How should I set this if my input format looks like:

2019-02-26T02:11:56.308466-08:00

? Excepted output is for example Feb. 21, 2019, 2:44 a.m. I can handle this but I don't know how to set up input format.

  • Possible duplicate of [How to format a JavaScript date](https://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date) – holydragon Feb 26 '19 at 10:33

1 Answers1

0

vue-good-table uses 'date-fns' for converting Date. you can find its code here.

I've tried similar code:

var dateFns = require("date-fns")
var v='2019-02-26T02:11:56.308466-08:00';
var dateInputFormat='MMM. DD, YYYY, hh:mm a.';// you can write every thing as format string here
var dateOutputFormat='MMM. DD, YYYY, hh:mm a.';
const date = dateFns.parse(v, dateInputFormat, new Date());
Con dateFns.format(date, dateOutputFormat);

it worked correctly. test your self here

since your input format is ISO compatible, you should not worry about input format. It works Even if you put wrong input Format in definition part...

note: java script date just have 3 digit after second part so your input count as 2019-02-26T02:11:56.308-08:00 and 0.000466 will be omitted..

note: The displayed value is converted to your local time zone.

e gh
  • 1