EDI\Reader::readUNBDateTimeOfPreperation PHP Method

readUNBDateTimeOfPreperation() public method

get message preparation time
    public function readUNBDateTimeOfPreperation()
    {
        //separate date (YYMMDD) and time (HHMM)
        $date = $this->readEdiDataValue('UNB', 4, 0);
        if (!empty($date)) {
            $time = $this->readEdiDataValue('UNB', 4, 1);
            $datetime = preg_replace('#(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)#', '20$1-$2-$3 $4:$5:00', $date . $time);
            return $datetime;
        }
        //common YYYYMMDDHHMM
        $datetime = $this->readEdiDataValue('UNB', 4);
        $datetime = preg_replace('#(\\d\\d\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)#', '$1-$2-$3 $4:$5:00', $datetime);
        return $datetime;
    }

Usage Example

Beispiel #1
0
 public function testReadUNBDateTimeOfPreperation()
 {
     $r = new Reader(__DIR__ . "/../files/example.edi");
     $Dt = $r->readUNBDateTimeOfPreperation();
     $this->assertEquals('2094-01-01 09:50:00', $Dt);
 }