[PHP-DB] Date and time issues
Subject: Re: [PHP-DB] Date and time issues If you are using MySQL, you may profitably investigate the function DATE_ADD( date, INTERVAL ) Ignatius J. Reilly Thanks Ignatius! Fred. This did it: $interval=1 HOUR; $subscr_text=1 sessie; } else if ($subscr_type==3) { $interval=90 DAY; $subscr_text=abonnement 3 maand; } else if ($subscr_type==12) { $interval=1 YEAR; $subscr_text=abonnement 12 maand; } $sql = SELECT * FROM subscriptions WHERE ((DATE_ADD(act_date, INTERVAL $interval) CURDATE()) AND (us_id= \$sel_us_id\));//validate subscritoin date $result = @mysql_query($sql, $connection) or die(Error #. mysql_errno() . : . mysql_error()); $num = @mysql_num_rows($result); if ($num!=0) //valid subscription all checks passed { - Original Message - From: Frederik Feys [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 04, 2002 10:32 PM Subject: [PHP-DB] Date and time issues Hi all, I searched for 5 hours, trying to solve my (newbie?) problem. I want to pick today's date and add XXX days to it. Its setup to validate membership period. Now my column is of date type. Aswell, I want to pick current time and add 1 hour to it. Here aswell, sessions expire after one hour. Can anybody help me? Thanks -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Date and time issues
Hi all, I searched for 5 hours, trying to solve my (newbie?) problem. I want to pick today's date and add XXX days to it. Its setup to validate membership period. Now my column is of date type. Aswell, I want to pick current time and add 1 hour to it. Here aswell, sessions expire after one hour. Can anybody help me? Thanks Fred My code: $time = getdate(); $yr = $time[year]; $mn = $time[mon]; $dy = $time[mday]; if (subscr_type==1) { //these users van only work 1 hour $exp_time=time()+3600; $new_exp_day = getdate(); } else if (subscr_type==3) { //3 months subscription(here time doesn't really matter) $offset = 90; } else if (subscr_type==12) { //1 year subscriptions $offset = 365; } $new_exp_day = strftime(%Y-%m-%d,mktime(0,0,0,$mn,$dy+$offset,$yr)); -- Frederik Feys [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date and time issues
I assume you are trying to insert into a mysql table column that is a date. insert into table (datecol) values (from_unixtime($new_exp_day)); Example output of from_unixtime: +---+ | from_unixtime(10) | +---+ | 2001-09-08 21:46:40 | +---+ Peter On Mon, 4 Nov 2002, Frederik Feys wrote: Hi all, I searched for 5 hours, trying to solve my (newbie?) problem. I want to pick today's date and add XXX days to it. Its setup to validate membership period. Now my column is of date type. Aswell, I want to pick current time and add 1 hour to it. Here aswell, sessions expire after one hour. Can anybody help me? Thanks Fred My code: $time = getdate(); $yr = $time[year]; $mn = $time[mon]; $dy = $time[mday]; if (subscr_type==1) { //these users van only work 1 hour $exp_time=time()+3600; $new_exp_day = getdate(); } else if (subscr_type==3) { //3 months subscription(here time doesn't really matter) $offset = 90; } else if (subscr_type==12) { //1 year subscriptions $offset = 365; } $new_exp_day = strftime(%Y-%m-%d,mktime(0,0,0,$mn,$dy+$offset,$yr)); -- Frederik Feys [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Date and time issues
If you are using MySQL, you may profitably investigate the function DATE_ADD( date, INTERVAL ) Ignatius J. Reilly - Original Message - From: Frederik Feys [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, November 04, 2002 10:32 PM Subject: [PHP-DB] Date and time issues Hi all, I searched for 5 hours, trying to solve my (newbie?) problem. I want to pick today's date and add XXX days to it. Its setup to validate membership period. Now my column is of date type. Aswell, I want to pick current time and add 1 hour to it. Here aswell, sessions expire after one hour. Can anybody help me? Thanks Fred My code: $time = getdate(); $yr = $time[year]; $mn = $time[mon]; $dy = $time[mday]; if (subscr_type==1) { //these users van only work 1 hour $exp_time=time()+3600; $new_exp_day = getdate(); } else if (subscr_type==3) { //3 months subscription(here time doesn't really matter) $offset = 90; } else if (subscr_type==12) { //1 year subscriptions $offset = 365; } $new_exp_day = strftime(%Y-%m-%d,mktime(0,0,0,$mn,$dy+$offset,$yr)); -- Frederik Feys [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php