- time: documentation ( source)
- strtotime: documentation ( source)
<?php
function update_ipdb() {
// check if we can update the database
//global $pcm_localization;
//$last_update = get_option( 'pcm_last_ipdb_update', '0|N/A' );
//$last_update = explode( '|', $last_update );
$last_update = '1445519411';
$last_month = strtotime( 'first wednesday of last month' );
$this_month = strtotime( 'first wednesday of this month' );
$today = time();
$recent_wed = $today > $this_month ? $this_month : $last_month; // identify most recent first wednesday (the nearest first wednesday in the past)
/* Only Update if the following criteria are met:
* 1. Current time is in the future of recent_wed and Last Update is not
* 2. Auto Update is enabled
*/
if ( $today > $recent_wed && $last_update < $recent_wed && $this->options->general->geolocation->enable_auto_db_update ) {
$ok = true;
// check if all went well
if ( $ok ) {
echo 'yep';
}
else {
echo 'no';
}
}
}
update_ipdb();