php-whois icon indicating copy to clipboard operation
php-whois copied to clipboard

What is a timezone for domain in expirationDate field?

Open piotrgradzinski opened this issue 1 year ago • 4 comments

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?

piotrgradzinski avatar Mar 04 '24 23:03 piotrgradzinski

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

ghost avatar Mar 08 '24 06:03 ghost

@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.

piotrgradzinski avatar Mar 08 '24 08:03 piotrgradzinski

@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.

ghost avatar Mar 08 '24 09:03 ghost

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

bessone avatar Apr 24 '24 07:04 bessone