The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Retrieving data from database
#41
Hello Mudmin, I have another question Smile

I have added a column to the database named "validity". I want to add dates at which a membership card was bought in there.

There are two kinds of cards...one that is valid 6 months and one that is valid 12 months.

I was hoping there would be an echo possible in which I could specify whether the card is 6 or 12 months valid so the displayed date would be set accordingly.

So for instance, a 6 month card bought on January 1st 2019 would echo out "valid till: July 1st 2019"
  Reply
#42
Can you give me an idea of how the date is stored in the db? Is it date or datetime?
  Reply
#43
Well, I have set it to just date right now (as an added time would be unnecessary).
So I guess the first of January 2019 will be stored as "2019-01-01

If datetime is better...than that is fine too Smile
  Reply
#44
Nope. That's perfect.
Give me a min.
  Reply
#45
Is that validity column in the users table of the db?
  Reply
#46
And random question...why don't you just add 6/12 months to the date before you add it to the db?
  Reply
#47
(01-22-2019, 12:18 PM)mudmin Wrote: Is that validity column in the users table of the db?

Yes, its is.

(01-22-2019, 12:19 PM)mudmin Wrote: And random question...why don't you just add 6/12 months to the date before you add it to the db?

ehm...because then I would have to calculate it myself and an error could be made.
If the computer does it...there can be no mistake..well...theoretically
  Reply
#48
So if you want to show 6 months from the date in the db it's
$date = date('Y-m-d', strtotime("+6 months", strtotime($user->data()->validity));
dump($date);

If you want to add the time before you put it in the db, it's...
$date = date('Y-m-d', strtotime("+6 months", strtotime(date("Y-m-d"))));
$db->update('users',$user->data()->id,['validity'=>$date]);
  Reply
#49
(01-22-2019, 12:25 PM)mudmin Wrote: So if you want to show 6 months from the date in the db it's
$date = date('Y-m-d', strtotime("+6 months", strtotime($user->data()->validity));
dump($date);

If you want to add the time before you put it in the db, it's...
$date = date('Y-m-d', strtotime("+6 months", strtotime(date("Y-m-d"))));
$db->update('users',$user->data()->id,['validity'=>$date]);

so, no echoing?
  Reply
#50
I'm not sure I'm understanding. So you have a date in the db that is the date that the item was purchased. How do you know if it is a 6 month or 12 month one?
  Reply


Forum Jump:


Users browsing this thread: 9 Guest(s)