io-developer / php-whois

PHP WHOIS provides parsed and raw whois lookup of domains and ASN routes. PHP 8.0 compatible (5.4+ old versions)
MIT License
437 stars 117 forks source link

What is a timezone for domain in expirationDate field? #218

Open piotrgradzinski opened 6 months ago

piotrgradzinski commented 6 months ago

When I'm getting basic information about the domain

<?php
use Iodev\Whois\Factory;

$domainInfo = $whois->loadDomainInfo("domain.com");
var_dump($domainInfo->expirationDate);

within the field expirationDate I'm getting a timestamp, which the I can convert to an object.

My question is, what timezone is used for that timestamp. I assume that the library is not providing this information as I wasn't able to fetch it via whois database. Is there a way to obtain the list of timezones for each domain type?

dehlirious commented 6 months ago

There is actually a way to get the timezone.

$var = $whois->loadDomainInfo('google.com');

var_dump($var->getExtra()['groups'][0]["Registry Expiry Date"]);

Returns with

string(20) "2028-09-14T04:00:00Z"

Manipulate it via

$dateTime = new DateTime($var->getExtra()['groups'][0]["Registry Expiry Date"]);
$dateTime->setTimezone(new DateTimeZone('America/New_York')); // Convert to New York timezone for example
echo $dateTime->format('Y-m-d H:i:s T'); // Output: 2028-09-13 03:00:00 EDT
piotrgradzinski commented 6 months ago

@dehlirious thank you very much for the suggestion! It looks like it really depends on the tld - for google.com we can fetch this information, but for example for google.pl I'm not able to find any date with zone information.

dehlirious commented 6 months ago

@dehlirious thank you very much for the suggestion! It looks like it really depends on the tld - for google.com we can fetch this information, but for example for google.pl I'm not able to find any date with zone information.

Ah, fair enough. Seems the isssue regards the whois server and the lack of information that they provide.

https://www.whois.com/whois/google.pl as an example, the timezone simply isn't given

Also https://www.whois.com/whois/google.no https://www.whois.com/whois/google.hk etc

From that point, I suppose it could be relatively assumed that the timezone is of the country the tld belongs to, from that assumption you could build an array to match these tld's with no timezone info to their respective country.

bessone commented 4 months ago

From my experience not all whois servers declare the timezone, and not all of them use the same one, especially those of registrars. Some have American time zones and others European ones