0

I try to convert the format: 2017-03-07T17:26:15-03:00 to a format like

yyyy/MM/dd HH:mm:ss for i can use DateTime in MySQL DataBase. I receveid those values from a XML file.

I find a lot of options here, but not working, i'm using PDI from Pentaho to convert the XML and save in a Database.

Use JavaScript to convert a date string with timezone to a date object in local time

Thanks so much.

Community
  • 1
  • 1

2 Answers2

0

You can extract individual date parts and combine them to get the desired string. Something like this:

var d = new Date('2017-03-07T17:26:00-03:00');
var result = d.getFullYear()+
    '/'+('0' + (d.getMonth()+1)).slice(-2)+
    '/'+('0' + d.getDate()).slice(-2)+
    ' '+('0' + d.getHours()).slice(-2)+
    ':'+('0' + d.getMinutes()).slice(-2)+
    ':'+('0' + d.getSeconds()).slice(-2);
console.log(result);
abhishekkannojia
  • 2,796
  • 23
  • 32
0

You cant use the calculator step, create a copy of field A, wich is the date that you want to change, and select the format date that you want, sorry for my english, is rusty, regards