Answer the question
In order to leave comments, you need to log in
How to get the registration date of a VK user?
I made a simple script to check if a page is alive for at least five days:
$text = file_get_contents("http://vk.com./foaf.php?id=1488");
preg_match('|<ya:created dc:date="(.*?)T|si', $text, $arr);
$d = date("Y-m-d", mktime(0, 0, 0, date('m'), date('d') - 5, date('Y')));
print "Created: {$arr[1]} | Compare date: {$d}";
if ($d > $arr[1]) {echo ' | page is ok.';} else {echo ' | error, page is new.';}
Answer the question
In order to leave comments, you need to log in
<?php
$text = file_get_contents("https://vk.com/foaf.php?id=1488");
preg_match('|ya:created dc:date="(.*?)"|si', $text, $arr);
$time_create = strtotime($arr[1]);
$time_current = time();
$check_time = 5/*дн.*/*86400; //5 полных суток
echo "Created: ".date("d-m-Y H:i:s", $time_create)."\n";
echo "Compare date: ".date("d-m-Y H:i:s", $time_current)."\n";
if(abs($time_current-$time_create) >= $check_time)
{
echo "С момента регистрации прошло больше 5 дн."."\n";
}
else
{
echo "С момента регистрации прошло меньше 5 дн."."\n";
}
Created: 02-12-2006 13:10:20
Compare date: 03-03-2020 22:49:32
More than 5 days have passed since registration.
$date_str = simplexml_load_file('https://vk.com/foaf.php?id=1')
->xpath('//ya:created/@dc:date')[0];
// 2006-09-23T20:27:12+03:00
$now = new DateTime();
$then = new DateTime($date_str);
$interval = $then->diff($now);
echo $interval->format('%a дней');
// 4910 дней
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question