[PHP] DateTime.Today.toString error. HELP ME

mirojantti

New Member
Nov 30, 2013
19
0
Hey nerds :p! Could someone of you help me a little bit? I'm getting this error:

Fatal error: Call to undefined function toString() in C:\xampp\htdocs\me.php on line 45

Why doesn't my toString() function work? Here's my code below:

PHP:
    $id = $user->id;
    $pvm = $user->lastdailycredits;
  

//Update the record
    if($pvm != DateTime.Today.toString("MM/dd")) //This is line 45
    {
    $updateQuery = "UPDATE users SET crystals = crystals + 1 WHERE id = $id";
    mysql_query($updateQuery) or die("Error: ".mysql_error());
    }

Please someone figure this out so I can make that my hotel users get 1 crystal every day. Thanks guys for reading this:)
 

JayC

Always Learning
Aug 8, 2013
5,505
1,401
Use HH for the Hours:
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")

My dumb dumb resources:
 

mirojantti

New Member
Nov 30, 2013
19
0
Use HH for the Hours:
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")

My dumb dumb resources:

But I don't want Hours. In my database there is in users table a lastdailycredits column. That column contains last logged in day's MM/dd. So I wan't to use month.
 

mirojantti

New Member
Nov 30, 2013
19
0
Haha got it working. Thanks anyway to all of you. Here's my working code
PHP:
    $id = $user->id;
    $pvm = $user->lastdailycredits;
    $nyt = new DateTime();
    $tulos = $nyt->format("m.d");
   
//Update the record
    if($pvm != $tulos)
    {
    $updateQuery = "UPDATE users SET crystals = crystals + 1, lastdailycredits = $tulos WHERE id = $id";
    mysql_query($updateQuery) or die("Error: ".mysql_error());
    }

Mods close this thread.
 

Users who are viewing this thread

Top