Timestamp to date

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
dharbitindy
Veteran Member
Posts: 101
Joined: 2019-05-26 18:38

Timestamp to date

Post by dharbitindy » 2019-09-26 01:25

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
Attachments
DateTime.JPG
DateTime.JPG (112 KiB) Viewed 2309 times

dharbitindy
Veteran Member
Posts: 101
Joined: 2019-05-26 18:38

Re: Timestamp to date

Post by dharbitindy » 2019-10-25 02:56

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);
}

lramirez
Veteran Member
Posts: 46
Joined: 2019-11-01 23:23

Re: Timestamp to date

Post by lramirez » 2020-05-22 14:24

// 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
Luis Ramirez R.

Post Reply