# Date based condition

**URL:** <https://www.phphelp.com/t/date-based-condition/20322>\
**Category:** General PHP Help\
**Created:** [May 22, 2013, 9:13am UTC](https://www.phphelp.com/t/date-based-condition/20322 "2013-05-22T09:13:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://www.phphelp.com/uploads/default/original/2X/2/243e9ed5d93c5653ce3186f18df16e019ce38445.png) [@system](https://www.phphelp.com/u/system)\
**Post date:** [May 22, 2013, 9:13am UTC](https://www.phphelp.com/t/date-based-condition/20322/1 "2013-05-22T09:13:30Z")

</div>

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 a clue

Thanks
