Jump to content

Recommended Posts

Hi,

 

I've got a db, and people sign up. Basically when they sign up there is reg_date timestamp...

 

part of my script is show the sign ups today, however on a monday I need to see who signed up after 5pm on friday, during saturday and during sunday...

 

ive got a qry running, and its

WHERE reg_date LIKE '<?php echo $todate; ?>%'

 

and im using

$tod = date('w')
if ($tod == '1') { //if day is monday show today, yesterday and day before
//HELP PLEASE
} else {
$todate = date('Y-m-d');
}

 

I dont know how to say show today, yesterday and the previous day.....

 

could someone point me in the right direction please?

Link to comment
https://forums.phpfreaks.com/topic/145786-solved-help-with-today/
Share on other sites

[php}$to_date = date('Y-m-d h:i:s');
$before_date = "2009-02-13 17:00:00";

$sql = "SELECT * FROM tabl_name WHERE reg_date BETWEEN '{$before_date}' AND '{$to_date}'";

 

That should get you on the right track. You may want to look into strtotime if you want to dynamically do this.

Something like this:

 

This MUST be ran on Monday for an accurate count

$to_date = date('Y-m-d h:i:s',strtotime('now -3 days 5pm'));

$sql = "SELECT * FROM tabl_name WHERE reg_date BETWEEN '{$before_date}' AND 'NOW()'";

 

Otherwise I did get this to work:

$to_date = date('Y-m-d h:i:s',strtotime('previous monday -3 days 5pm'));

$sql = "SELECT * FROM tabl_name WHERE reg_date BETWEEN '{$before_date}' AND 'NOW()'";

Hey guys,

 

Thanks for all the suggestions, I've now got...

 

    $tod = date('w')

if ($tod == '1') {
    $todate = date('Y-m-d h:i:s',strtotime('now -3 days 5pm'));
} else {
    $todate = date('Y-m-d');
}

 

looks like it should work, as its basically if $tod is monday, show last 3 days from 5pm, if its not monday show todays subscriptions...

 

i'm guessing the only way to get to test it is to wait till monday lol...

 

Thanks for all the help!!!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.