[thelist] Convert string to date
~kristina
kristina at kfx-design.co.uk
Wed Jul 10 02:10:01 CDT 2002
Dear list,
I have a small db using mysql & php.
I'm trying to convert a string that is entered by a 'user' via select
options into a date in the future. With the idea that when the expirydate
== today it will delete itself.
The part I need help with is converting the string to a date.
the date is in this format:
<tr>
<td>Delete record on:</td>
<td>
<select name="deleteday" size="1">
<option> </option>
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>/
<select name="deletemonth" size="1">
<option> </option>
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>/
<select name="deleteyear" size="1">
<option> </option>
<option>2002</option>
<option>2003</option>
<option>2004</option>
<option>2005</option>
</select>
</td>
</tr>
How is
deleteday
deletemonth
deleteyear
converted to a proper date
is it as simples as
$deleteday = d
$deletemonth = m
$deleteyear = Y
which are all = $expirydate
So far I have:
//convert string to date
function makedate($expirydate){
$deleteday = date("d");
$deletemonth = date("m");
$deleteyear = date("Y");
}
But it isn't doing anything.......!!
as then I think that all I need to do is add a query that tests to see if
$expirydate == to today if so delete:
$query = "DELETE * FROM tableName WHERE $expirydate=now()";
When I created the table I did this (which I'm not sure is correct
either)
CREATE TABLE tableName (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
timestamp DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
expirydate DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,
deleteday TEXT NOT NULL,
deletemonth TEXT NOT NULL,
deleteyear TEXT NOT NULL,
[rest of table info]
);
--
tia
~kristina
kristina at kfx-design.co.uk
http://kfx-design.co.uk/
More information about the thelist
mailing list