How to find a domain's registered date and expires date?

Iam coding a website, list custom’s domain, when domain will expires, the system send email automantic. but domains list in my database are not registered from my website, I know how to use php to get whoise information, but can’t receive an exact expires date!

i found a project that can do this well, any interested this could search: phpwhois