This topic is locked

Calculate days between two dates

5/24/2012 9:38:51 PM
PHPRunner General questions
J
joiresende author

Need to calculate how many days to win a particular product.Something like
('DateDiff(now()' - " .$datatmp["data_final"].")

only it does not work well Any help will be appreciated

C
ckapote 5/25/2012

for inspiration pls check following link
http://www.asprunner.com/forums/topic/7631-days-calculations-between-two-dates/pagehldaysfromsearch1

J
joiresende author 5/25/2012

I'll try to explain what I'm wondering, because my English is very bad (use google translator).

I use the script below to send e-mails automatically when a date expires.

It works perfectly. What I need is to be shown how many days have passed since the date has expired. Wanted it to be shown how many days since the day it was created.

(date of creation - today = days of creation)
_$msg="This product was created to "X" days";


Any help and hint will be welcome._Script date expires
<?php

include("include/dbcommon.php");

global $dal;

$dalTableName = $dal->Table("TableName");

$rstmp = $dalTableName->Query("DateDiff(now(),ExpiryDate)>0","");;

while ($datatmp = db_fetch_array($rstmp))

{

//send email for each record

$email=$datatmp["EmailField"];

//EmailField is your actual field name

$msg="This event was expired \r\n";

$msg.="FieldName1: ".$datatmp["FieldName1"]."\r\n";

$msg.="FieldName2: ".$datatmp["FieldName2"]."\r\n";

$subject="Expired";

runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg));

}

//FieldName1, FieldName2 and ExpiryDate are your actual field names, TableName is your actual table name

?>