Jump to content

strtotime()


xyn

Recommended Posts

Hey.

I'm having a small problem with my sql syntax. Basically

I wanted to check how many e-mails a member is

allowed to send out.  then using sql num rows to see how

many they have sent.

 

Well i used date("j/m/y, h:i:s", strtotime("today")); and i

don't think this is the correct method.

 

my code:

while(list($max_mail, $max_tmout) = mysql_fetch_array($sql_limit_perm))
{
$email_maximum = $max_mail;
$email_timeout = $max_tmout;
switch($email_maximum)
{
	case x:
			$ignore_mail_max = 1;
			break;
	default:
			$ignore_mail_max = 0;
			break;
}
}

if($ignore_mail_max != "1") 
{
$sql_senders_limit = mysql_query("SELECT `id` 
FROM `asc_emaillogs` 
WHERE `sentby`='".$_SESSION['userName']."' 
AND `senton`='".date("j/m/Y, H:i:s", strtotime("Today"))."'");

if(mysql_num_rows($sql_senders_limit) >=$email_maximum)
{
	$error[] = "You have reached your limit today.";
}
}

 

the ignroe is for mods, super-mods, admins and super-admins

thanks,

ash

Link to comment
https://forums.phpfreaks.com/topic/62069-strtotime/
Share on other sites

I would suspect this is just a simple issue to do with how you are storing the date the email was sent on. What field type are you using to store this? If you are using a datetime field, then you are going to need to select all of those dates and times which are between the beginning of the start of the current day, and the current time.

 

If you are using a date field, then you'll just need a simple match on the date. If either of these are the case, take a look at the way the dates are actually stored. They are stored as yyyy-mm-dd. You'll need to format your date in this way too.

 

Finally, if you are storing your date in a varchar field(bad idea) then you can use the mysql function UNIX_TIMESTAMP to compare with a php generated timestamp for the current day.

Link to comment
https://forums.phpfreaks.com/topic/62069-strtotime/#findComment-309041
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.