Page 1 of 1

Timestamp to date

Posted: 2019-09-26 01:25
by dharbitindy
Hello,

I'm trying to convert a timestamp to a "readable" date/time in the Log file that is shown in the Udemy customization course. The field used in the AppGini application is "ts" with a data type of "Big Int". In the running application, this shows up as Unix data if I remember right, or more simply, just numbers. The code is in the hooks/_global.php file.

Attached is a screen shot of my _global.php file, and I'd like to know what and where to add the modified code to change this to a human readable date and time.

Much appreciated,
David

Re: Timestamp to date

Posted: 2019-10-25 02:56
by dharbitindy
This was a simple fix thanks to Ahmed. Below is the solution to this. Specifically the line with $ts = date('Y-m-d H:i:s');


function login_failed($attempt, &$args){
$ip = $_SERVER['REMOTE_ADDR'];
$ts = date('Y-m-d H:i:s');
$details = makeSafe("User login failed. Username: {$attempt['username']}. Password: {$attempt['password']}");
sql("insert into logs set ip='{$ip}', ts='{$ts}', details='{$details}'", $eo);
}

Re: Timestamp to date

Posted: 2020-05-22 14:24
by lramirez
// I did this in my database ... following your examples ... thank you very much ...

function login_ok($memberInfo, &$args) {
$ip = $_SERVER['REMOTE_ADDR'];
$ts = date('d-m-yy H:i:s');
$details = makeSafe("ACCESO AUTORIZADO. Usuario que ingresa: {$memberInfo['username']} {$memberInfo['group']}. Contraseña_válida:
{$memberInfo['password']}");
sql("insert into logs set ip='{$ip}', ts='{$ts}', details='{$details}'", $eo);

return '';
}

function login_failed($attempt, &$args) {
$ip = $_SERVER['REMOTE_ADDR'];
$ts = date('d-m-yy H:i:s');
$details = makeSafe("ERROR ACCESO NO AUTORIZADO. Usuario: {$attempt['username']} {$attempt['group']}. Contraseña: {$attempt['password']}");
sql("insert into logs set ip='{$ip}', ts='{$ts}', details='{$details}'", $eo);
}

// It is working for me, but if you see any error or adjustment I would appreciate it... thank you