Date based condition

I’d like to add a date based condition to the code I have to reset the counter on every Sunday 00:00:00 but I can’t figure out how to do it.

This is what I have, but it doesn’t reset the counter to 0.

[php]//COUNT PAGEVIEWS
function wpb_set_post_views($postID) {
$count_key = ‘wpb_post_views_count’;
$count = get_post_meta($postID, $count_key, true);
$today = date(‘l H:i:s’);
if($count==’’ || $today == ‘Sunday 00:00:00’) {
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, ‘0’);
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}[/php]

Has anyone an idea to do this?

Thanks

Thank you all for the many and very fast responses. NOT.

I got some answers on a real forum.

Sleep tight!

Congrats, have a cookie. I was sleeping when you posted your thread, and I assume a lot of other people were.

Whining about “OMG I GOTS HELP ELSEWHERE YOU ALL SUCK” also can’t help but to make me think you consider helpers as slaves

Sponsor our Newsletter | Privacy Policy | Terms of Service