Graham
Graham

Reputation: 81

Get timestamp from a webpage?

Is there a way to get the timestamp from a webpage? In this case, news stories webpage. I have tried isolating them in the string contents of the XHTML, but there is too much variation. i have searched all over, but all anyone is able to do is get the current date

Upvotes: 0

Views: 5838

Answers (2)

Hugo Delsing
Hugo Delsing

Reputation: 14173

You can get the header with the code below. Not many websites implement the last-modified date though.

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_NOBODY, TRUE); // remove body
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$head = curl_exec($ch); 
?>

Upvotes: 0

Mr Moose
Mr Moose

Reputation: 6344

Can you check the Last-Modified response header. See for details of the full list of headers.

Upvotes: 1

Related Questions