Convert datetime to db format

Goodmorning,
how can I convert a datetime value formatted using user preferences format in db format?
I need, during edit a record in my custom module, to check on chage datetime field, if there is other record with the same datetime.
I create a post request using ajax with the datetime selected by user as parameter, but the vale is formatted using user preferences than, before to made the query, I must convert the selected value to datetime using db format.
Can someone helps me?
Thank you so much
B.

$GLOBALS[‘timedate’]->to_db_date_time($user_date, $user_time);

/include/TimeDate.php

Check this file for all available functions.

1 Like