Jump to content

forming the date() correctly


reaper7861

Recommended Posts

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

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

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

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.