PHP Date()ing logic.....

This is a discussion on PHP Date()ing logic..... within the PHP General forums, part of the PHP Programming Forums category; Hi, I'm just screwing around with the date() function and timestamps but have run into a little logic problem... ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-16-2003
Ryan A
 
Posts: n/a
Default PHP Date()ing logic.....

Hi,
I'm just screwing around with the date() function and timestamps but have
run into a little logic problem...
So far (as you can see with the below posted code) I can manipulate
days,hours and minutes...any idea on how to do months and years?
Lastly the goal of this is to make take all the parameters and make 1
timestamp out of it...any ideas? or links?
The code is really easy to understand and was taken from the manual but have
commented it a bit none the less, so it should be real easy to understand
even without executeing it.

Thanks in advance.

Cheers,
-Ryan
P.S around 20 lines of simple code below, if testing code copy and name your
file t1.php.....

<html><head><title> Testing Dates</title></head>
<body><form type=get action=t1.php><input type=text name=m><input type=text
name=h><input type=text name=d><input type=submit></form></body></html>
<?php
## minutes ##
echo "<br>**MINUTES**<br>";
$minutes=$_GET['m'];if(!isset($_GET['m'])){$minutes=1;}
echo 'year - mo-da-hr-m - s : - : <b>$minutes</b> is set to
'.$minutes.'<br>';
echo date("Y-m-d-H-i-s")."&nbsp; &nbsp; Current<br>";
echo date("Y-m-d-H-i-s",(time() + $minutes*60));
## hours ##
echo "<br><br>**HOURS**<br>";
$hours=$_GET['h'];if(!isset($_GET['h'])){$hours=1;}
echo 'year - mo-da-hr-m: - : <b>$hours</b> is set to '.$hours.'<br>';
echo date("Y-m-d-H-i")."&nbsp; &nbsp; Current<br>";
echo date("Y-m-d-H-i",(time() + $hours*3600));
## days ##
echo "<br><br>**DAYS**<br>";
$days=$_GET['d'];if(!isset($_GET['d'])){$days=1;}
echo 'year - mo-da-hr-m : - : <b>$days</b> is set to '.$days.'<br>';
// $days=24*3600;
echo date("Y-m-d-H-i")."&nbsp; &nbsp; Current<br>";
echo date("Y-m-d-H-i",(time() + $days*(24*3600)));
?>
Reply With Quote
  #2 (permalink)  
Old 10-16-2003
Becoming Digital
 
Posts: n/a
Default Re: [PHP] PHP Date()ing logic.....

If you want to manipulate months in this manner, you'll first need a month input box. Once you've got that covered, it's just a matter of using mktime() to create the appropriate date.

Edward Dudlik
"Those who say it cannot be done
should not interrupt the person doing it."

wishy washy | www.amazon.com/o/registry/EGDXEBBWTYUU



----- Original Message -----
From: "Ryan A" <ryan@coinpass.com>
To: <php-general@lists.php.net>
Sent: Thursday, 16 October, 2003 15:42
Subject: [php] PHP Date()ing logic.....


Hi,
I'm just screwing around with the date() function and timestamps but have
run into a little logic problem...
So far (as you can see with the below posted code) I can manipulate
days,hours and minutes...any idea on how to do months and years?
Lastly the goal of this is to make take all the parameters and make 1
timestamp out of it...any ideas? or links?
The code is really easy to understand and was taken from the manual but have
commented it a bit none the less, so it should be real easy to understand
even without executeing it.

Thanks in advance.

Cheers,
-Ryan
P.S around 20 lines of simple code below, if testing code copy and name your
file t1.php.....

<html><head><title> Testing Dates</title></head>
<body><form type=get action=t1.php><input type=text name=m><input type=text
name=h><input type=text name=d><input type=submit></form></body></html>
<?php
## minutes ##
echo "<br>**MINUTES**<br>";
$minutes=$_GET['m'];if(!isset($_GET['m'])){$minutes=1;}
echo 'year - mo-da-hr-m - s : - : <b>$minutes</b> is set to
'.$minutes.'<br>';
echo date("Y-m-d-H-i-s")."&nbsp; &nbsp; Current<br>";
echo date("Y-m-d-H-i-s",(time() + $minutes*60));
## hours ##
echo "<br><br>**HOURS**<br>";
$hours=$_GET['h'];if(!isset($_GET['h'])){$hours=1;}
echo 'year - mo-da-hr-m: - : <b>$hours</b> is set to '.$hours.'<br>';
echo date("Y-m-d-H-i")."&nbsp; &nbsp; Current<br>";
echo date("Y-m-d-H-i",(time() + $hours*3600));
## days ##
echo "<br><br>**DAYS**<br>";
$days=$_GET['d'];if(!isset($_GET['d'])){$days=1;}
echo 'year - mo-da-hr-m : - : <b>$days</b> is set to '.$days.'<br>';
// $days=24*3600;
echo date("Y-m-d-H-i")."&nbsp; &nbsp; Current<br>";
echo date("Y-m-d-H-i",(time() + $days*(24*3600)));
?>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:01 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0