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
Timestamp to date
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Timestamp to date
- Attachments
-
- DateTime.JPG (112 KiB) Viewed 2342 times
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Re: Timestamp to date
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);
}
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
// 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
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.