0

I am using Whois Library to get Domain Information . but i just Want to get Domain Expiry Date . When I echo $domain->info(); i get lot of information from domain and also get expire date on 298 line , how can i get only expiry date ?

here is php code

include '../src/Phois/Whois/Whois.php';

$sld = 'xyz.net';

$domain = new Phois\Whois\Whois($sld);
$whois_answer = '<pre>'.$domain->info().'</pre>';
echo $whois_answer;

and after Echo Result is that :

  Domain Name:XYZ.NET
  Registry Domain ID: 2140087625_DOMAIN_NET-VRSN
  Registrar WHOIS Server: whois.PublicDomainRegistry.com
  Registrar URL: http://www.publicdomainregistry.com
  Updated Date: 2017-07-05T14:07:21Z
  Creation Date: 2017-07-05T12:24:22Z
  Registry Expiry Date: 2018-07-05T12:24:22Z
Hashaam
  • 83
  • 1
  • 1
  • 9
  • What is the output you are seeing? Is it in array format? – ThomasVdBerge Apr 27 '18 at 12:00
  • _"also get expire date on 298 line"_ - We can't see your screen. You need to post all relevant code and data in your question. – M. Eriksson Apr 27 '18 at 12:00
  • 2
    check again Please – Hashaam Apr 27 '18 at 12:05
  • 1
    The library you're using only seem to get and return a string with all the information. After testing the library with a few different domains and TLD's, it seems like the format of the string can differ, so there isn't really one global way to fix this, as I see it. You would need to test all TLD's and check all the different formats. – M. Eriksson Apr 27 '18 at 12:54
  • I guess you will have to parse that string in one or another way. you cloud use Regex to get your desired Date. But be aware, that not TLD's from Whois Servers do give back an Expire Date. Some TLD's do not return this Information at all. Future More The Expire Date declaration string can differ from TLD and Whois Server. So you will have to do a lot of research and testing if you want to use it for different TLD's. – S.Gartmeier Apr 27 '18 at 12:58

1 Answers1

0

Use code from this answer. I would add that to find the value of the expiration date, in case when it's not presented in ['regrinfo']['domain']['expires'] response array key, you can make up a regular expression. Foresee the case that for some domains the required data in the response can not be at all.

You can also use any of the popular web services, for example whoAPI or DomainTools.

camelsWriteInCamelCase
  • 1,655
  • 1
  • 10
  • 15
  • For gTLD domains the format will be the same and the data always present, this is an ICANN requirements. The poster did not specify which TLD. The problem is more complex if you have to handle ccTLDs. – Patrick Mevzek Apr 28 '18 at 23:28