Jonjjboy
System Exploitation Strategist
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
300 XP
This tutorial will teach you on how to add days in a date using PHP.
I uses PHP strtotime to add days to the current date. This tutorial is useful for thus creating a system that needs a reservation using a range of date.
Follow the steps bellow to learn this tutorial.
Creating Our Form
Tis code will display our form with the current date and a textbox that allow you to input the number of days you want to add in your current date.
Copy the code bellow and save it as "index.php".
Creating Our Script That add Days to Date
Copy the code bellow and paste it above our form in "index.php".
That's all the running version of this tutorial is can be found in zip file attach with this tutorial.
Download
I uses PHP strtotime to add days to the current date. This tutorial is useful for thus creating a system that needs a reservation using a range of date.
Follow the steps bellow to learn this tutorial.
Creating Our Form
Tis code will display our form with the current date and a textbox that allow you to input the number of days you want to add in your current date.
Copy the code bellow and save it as "index.php".
- <form
action
=
"index.php"
method
=
"GET"
>
- <span
style
=
"display: inline-block; width: 150px;"
>
Date</
span
><input
type
=
"text"
name
=
"date"
required=
"required"
value
=
"<?php echo date("
m/
d/
Y") ?>
" /><br
>
- <span
style
=
"display: inline-block; width: 150px;"
>
Number of days</
span
><input
type
=
"text"
name
=
"numberofdays"
value
=
"<?php echo $nd ?>
" autocomplete="off" /><br
>
- <span
style
=
"display: inline-block; width: 150px;"
>
Result</
span
><input
type
=
"text"
name
=
"result"
value
=
"<?php echo $result ?>
" /><br
>
- <span
style
=
"display: inline-block; width: 150px;"
>
</
span
><input
type
=
"submit"
value
=
"Calculate"
/
>
- </
form
>
Creating Our Script That add Days to Date
Copy the code bellow and paste it above our form in "index.php".
- <?php
- if
(
isset
(
$_GET
[
"date"
]
)
)
{
$date
=
$_GET
[
"date"
]
;
}
else
{
$date
=
date
(
"m/d/Y"
)
;
}
;
- if
(
isset
(
$_GET
[
"numberofdays"
]
)
)
{
$nd
=
$_GET
[
"numberofdays"
]
;
}
else
{
$nd
=
0
;
}
;
- $result
=
date
(
'm/d/Y'
,
strtotime
(
$date
.
' + '
.
$nd
.
' days'
)
)
;
- ?>
That's all the running version of this tutorial is can be found in zip file attach with this tutorial.
Download
You must upgrade your account or reply in the thread to view hidden text.