blank dates save as current date

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

blank dates save as current date

Post by D Oliveira » 2018-05-08 19:43

Hello, my issue is that when I save a record with a blank date it gets the current date. I use fpdf to export a 'work order' file, whenever I put a specific date it works fine, but when I leave it blank it gets the current date (today's date). Anyone can shed some light on how to solve this?

https://ibb.co/eq0ddn
https://ibb.co/egQGW7
https://ibb.co/dmx24S

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: blank dates save as current date

Post by pbottcher » 2018-05-08 20:40

Hi,

are you using any hooks to check on the date? PHP or JS?
Can you check that in the form you are submitting the date is empty and in the DB the date is set to the current date?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: blank dates save as current date

Post by D Oliveira » 2018-05-09 15:46

i forgot to add the .php file that handles the fdpf, it think that might be it, I think checking the lenght first might solve the issue

Code: Select all


$date1 = $gwoid['gdatesched'];
$date =date_create($date1);

$pdf->SetY(29.2);
$pdf->SetX(137);
$pdf->Cell(90 ,5,date_format($date,"M/d"),0,1);


pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: blank dates save as current date

Post by pbottcher » 2018-05-09 17:21

Hi,
ok, but now it would be necessary to understand what/how your $gwoid['gdatesched'] is filled. If it is empty, this is what I assume, date_create will create the date object as the current date. So you should check what is in there and apply your logic accordingly.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: blank dates save as current date

Post by D Oliveira » 2018-05-09 19:25

thanks that worked

Code: Select all

$date1 = $gwoid['gdatesched'];

if (strlen($date1) > 2){
    $date =date_create($date1);

$pdf->SetY(29.2);
$pdf->SetX(137);
$pdf->Cell(90 ,5,date_format($date,"M/d"),0,1);
} 
else 
{
    //echo "should be blank.";
}


Post Reply