I have create function time zone Asia/Indonesia/Jakarta
Entity\User.php
namespace App\Model\Entity;
use Cake\ORM\Entity;
use Cake\I18n\Time;
public static function waktuDibuat()
{
Time::setToStringFormat('dd-MM-yyyy HH:mm:ss');
$Dibuat = Time::now();
}
then I call function
waktuDibuat();
from
Controller\UsersController.php
namespace App\Controller;
use App\Controller\AppController;
use App\Model\Table\UsersTable;
27 public function add()
28 {
29 $setWaktu = UsersTable::waktuDibuat();
30 $user = $this->Users->newEntity();
31 if ($this->request->is('post')) {
32 $user = $this->Users->patchEntity($user, $this->request->getData());
33 if ($this->Users->save($user)) {
34 $this->Flash->success(__('Pengguna berhasil ditambahkan.'));
35 return $this->redirect(['action' => 'index']);
36 }
37 $this->Flash->error(__('Pengguna gagal disimpan, Coba lagi.'));
38 }
39 $this->set(compact('user'));
40 }
The messeage shown error is
Call to undefined method App\Model\Table\UsersTable::waktuDibuat()
Error in: ROOT\src\Controller\UsersController.php, line 29
I hope someone help me to fix this line error, thanx