Comparing postgresql dates

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
barb woolums
Forum Contributor
Posts: 134
Joined: Sun Feb 08, 2009 9:52 pm

Comparing postgresql dates

Post by barb woolums »

I have a signup date in a postgresql database in the format yyyy-mm-dd

In php I want to determine if this date is greater than a certain date. How do I do this?

I tried the code below but it obviously doesn't work as they are strings

Code: Select all

if ($signup > '2013-02-23') {
	code...
}
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Comparing postgresql dates

Post by Benjamin »

You can convert it to a Unix Timestamp using strtotime() http://us2.php.net/manual/en/function.strtotime.php
Post Reply