While working on a PHP script that builds EPUB 3.0.1 content from external data, I encountered a situation where EPUBCheck complains about a valid ISO8601 date-time string in two places in the container file. The string comes from the following PHP code.
$isoDate=date(DateTime::ISO8601);
The same date string appears in both places of the container. One yields a warning and the other an error. I am positive that the string is valid per the ISO8601 standard quoted in the warning message. So why does this happen?
Below is the top portion of my container.opf file and the errors I got from the online validator at http://validator.idpf.org. The validator used EPUBCheck version 4.1.1.
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://www.idpf.org/2007/opf" xmlns:opf="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="uuid_id">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:opf="http://www.idpf.org/2007/opf">
<dc:identifier id="uuid_id" opf:scheme="uuid">508c6b12-b888-4d7b-9c58-c25d8fba7846</dc:identifier>
<dc:title>Franklin's Palindromedary</dc:title>
<dc:language>en</dc:language>
<dc:creator>Ray N. Franklin</dc:creator>
<dc:date>2020-12-09T14:06:40-0700</dc:date>
<meta property="dcterms:modified">2020-12-09T14:06:40-0700</meta>
</metadata>
The first offending line is #8, declaring the dc:date value. Here's the warning.
WARNING: content.opf, line 8, position 45: Date value '2020-12-09T14:06:40-0700' does not follow recommended syntax as per http://www.w3.org/TR/NOTE-datetime:Missing minute field.
The next line declares the required meta property dcterms:modified using the same date string. It garners an error.
ERROR: content.opf, line 9, position 36: Error while parsing file: dcterms:modified illegal syntax (expecting: 'CCYY-MM-DDThh:mm:ssZ')
Please note that I am posting this question so I can answer it, because I did eventually find a solution. I want to give the full answer here because everywhere else I found only pieces of the puzzle.