Reputation: 17636
Getting the following error when I try to put the date in the follwing format:
date_format(date_create($this->output->publication_date), 'Y-m-d H:i:s');
"Invalid value for: Invalid format: \"2015-04-14 00:00:00\" is malformed at \" 00:00:00\"
What is the correct format that is needed to set the publication date when uploading a video to youtube?
According to the youtube api the format should be
YYYY-MM-DDThh:mm:ss.sZ
How to do this correctly in PHP?
Upvotes: 2
Views: 2774
Reputation: 39460
You need to use the ISO 8601 format, see here for the correct selector.
As example, you can use it in your code as follow:
$date = date_create($this->output->publication_date);
$formatted = $date->format('c');
or
date_format(date_create($this->output->publication_date), 'Y-m-d\TH:i:s.Z\Z');
hope this help
Upvotes: 3