function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PtitFredPtitFred 

How to use Date in WHERE clause ?

Hello, I try to make a request with a filter on the field LastModifiedDate in PHP but I don't know the PHP function to use...

$request = "select Id from Opportunity where LastModifiedDate > ". ? ."";

I read that It had to use gmdate(DATE_ISO8601) but I don't understand how. I'm using php 4.2.3

Thanks !
SynchroSynchro
I suspect you read that example in one of my posts - that constant is new in PHP 5.1, so it won't work for you. An ISO 8601 date looks like this: 2005-08-15T15:52:01+0000, which you can create using this pattern:

gmdate('%Y-%m-%d%TH:%i:%s+0000');

Nte that that will render the current date/time in GMT. If you want to insert a different date, supply it through a second parameter to the function, for example:

gmdate('%Y-%m-%d%TH:%i:%s+0000', strotime('last week'));
PtitFredPtitFred
Thanks for you answer.

I found this and it works :

function get_iso_8601_date($int_date) {
$date_mod = date('Y-m-d\TH:i:s', $int_date);
$pre_timezone = date('O', $int_date);
$time_zone = substr($pre_timezone, 0, 3).":".substr($pre_timezone, 3, 2);
$date_mod .= $time_zone;
return $date_mod;
}

... where LastModifiedDate > ".get_iso_8601_date(time())." ...

See you soon !
SynchroSynchro
Aghh... sorry, I was mixing up my date function syntax... Glad you found a solution.