Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

article:published_time date format

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?

like image 443
orhun Avatar asked Sep 20 '25 02:09

orhun


2 Answers

The c format option to date() is what you're looking for

 $date = date('c', 1407178292); // the timestamp is the second parameter
like image 66
John Conde Avatar answered Sep 22 '25 17:09

John Conde


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

like image 22
mjk Avatar answered Sep 22 '25 16:09

mjk