reaper7861 Posted November 9, 2006 Share Posted November 9, 2006 i need to be able to make the following code get the creation date +30 days all the dates are set by DATE in mysql. any help would be greatly appreciated. This is my problem area $creationdate + (60*60*24*30) is this correct if not pls let me know what the correct syntax is thank you. [code]$creationdate = $r['bwreset']; $currentdate = date("Y-m-d"); if($currentdate >= ($creationdate + (60*60*24*30))){ $ResetBW = "Update members set used_bw = '0',bwreset ='$currentdate' where username = '" . $_POST['user_uname'] ."'"; mysql_query($ResetBW) or die("BWRESET Failed"); [/code] Link to comment Share on other sites More sharing options...
kenrbnsn Posted November 9, 2006 Share Posted November 9, 2006 No, the date() function returns a string, you want to compare UNIX timestamps. (The number of seconds since 1-1-1970).Try something like this:[code]<?php$creationdate = strtotime($r['bwreset']); $currentdate = time(); if($currentdate >= ($creationdate + (60*60*24*30))){ $ResetBW = "Update members set used_bw = '0',bwreset ='$currentdate' where username = '" . $_POST['user_uname'] ."'"; mysql_query($ResetBW) or die("BWRESET Failed using the query: $ResetBW<br>". mysql_error());?>[/code]Ken Link to comment Share on other sites More sharing options...
reaper7861 Posted November 9, 2006 Author Share Posted November 9, 2006 TYVM one last question i want to show the $r['bwreset'] as a date 30 days in the future in a Y-m-d format so i can see when it will reset i know how to echo and such but i just need to know how to show it 30days in the future as a date.Thanks once again for your uber help Link to comment Share on other sites More sharing options...
roopurt18 Posted November 9, 2006 Share Posted November 9, 2006 If you are working with a date field within MySQL, you can use the +/- INTERVAL function of MySQL.SELECT NOW() + INTERVAL 30 DAYS AS ThirtyDaysFromNow FROM tbl WHERE 1 LIMIT 1 Link to comment Share on other sites More sharing options...
reaper7861 Posted November 10, 2006 Author Share Posted November 10, 2006 ok ive already pulled the information from the database in a var called $bwreset, so can you show me the syntax in which that would go from my members table.thanks Link to comment Share on other sites More sharing options...
reaper7861 Posted November 10, 2006 Author Share Posted November 10, 2006 nevermind its complete i had to rewrite it differently, thanks for the help guys. Link to comment Share on other sites More sharing options...
Recommended Posts