how to insert today date automatically

Questionshow to insert today date automatically
Patrick Chevalier asked 1 month ago
4 Answers
Cedric answered 1 month ago

Bonjour Patrick,

I think you can use something like this

$col = array();
$col[“title”] = “Start Date”;
$col[“name”] = “Start_Date”;
$col[“width”] = “8”;
$col[“sortable”] = true; // false this column is not sortable
$col[“search”] = true; // false this column is not searchable
$col[“editable”] = true;
$col[“formatter”] = “date”;
$col[“editoptions”][“defaultValue”] = date(“m/d/Y”);
$cols[] = $col;

Patrick Chevalier answered 1 month ago

Thank you for your replay. I have yet done exactly that, but that does not run: after an add, I can just find a \’NULL\’ in the database, not the date. Regards Patrick

Abu Ghufran Staff answered 4 weeks ago

Hello,

There are 2 ways:

  1. Use database field default value to CURRENT_TIMESTAMP and it will save current time of insert query.
  2. Use on_insert callback event handler and in your callback php function, you can set this field to current date time.

For second case, you can refer this link: https://www.gridphp.com/docs/grid-events/

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Patrick Chevalier answered 3 weeks ago

Thank you for reply,

I had took the first solution

Regards

Your Answer

6 + 16 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?