i save the dates via php time() format in mysql.. for example: 1407178292
how can i convert it to a datetime for schema/article:published_time on meta tags?
<meta property="article:published_time" content="??" />
all samples i saw on net are lie this:
<meta property="article:published_time" content="2013-11-12T19:57:40+00:00" />
i mean: i must convert time() format to 2013-11-12T19:57:40+00:00 etc..
and also, can/should i use published_time in NewsArticle?
could someone help me?
The c
format option to date()
is what you're looking for
$date = date('c', 1407178292); // the timestamp is the second parameter
Most trivially:
$formatted_date = date('c', time());
Presuming you're on PHP5, which added support for ISO 8601 dates using the 'c' formatter.
Full documentation: http://php.net/manual/en/function.date.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With