I am using alphanumeric date columns from my DB2 table that are formatted as YYYMMDD.
I need to covert these columns to m/d/Y in the front-end.
I tried to using
->getFormatter('Format::datetime', array(
'from' => 'Ymd',
'to' => 'm/d/Y'
) )
unfortunately it return null values .
Here is the piece of code I am using. I seems that I may not have this right.
Field::inst('NWFF.MTTRAN.createDate')
->getValue('')
->getFormatter(function ($val, $data, $opts) {
switch ($data['NWFF.MTTRAN.TNSTAT']) {
case 'P':
return $data['NWFF.MTTRAN.TNWDTE'];
}
switch ($data['NWFF.MTTRAN.TNPM#']) {
case ($data > 0):
return $data['NWFF.MTTRAN.TNPDTE'];
}
switch ($data['NWFF.MTTRAN.TNDT#']) {
case ($data > 0):
return $data['NWFF.MTTRAN.TNDDTE'];
}
switch ($data['NWFF.MTTRAN.TNWO#']) {
case ($data > 0):
return $data['NWFF.MTTRAN.TNWDTE'];
}
})
->getFormatter('Format::datetime', array(
'from' => 'Ymd',
'to' => 'm/d/Y'
) ),
Thanks in advance