DelphiFAQ Home Search:
General :: Programming :: perl :: mysql
How to work mysql from perl. This site is mainly built with mysql and perl (and some php)


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Convert a date from Apache's string format to mysql's date format in perl


Apache logs dates in this form: [25/Apr/2005:11:45:59 -0400] and I need to insert this string in a mysql table as a datetime value.
How can I convert it?


mysql has powerful date handling functions, which unfortunately vary from version to version substantially.
You may use the following perl code instead - it converts



2005-04-25 11:45:59

%mo = (
 $time = substr($time,7,4) . '-' . $mo{substr($time,3,3)} . '-' . substr($time,0,2) . ' ' . substr($time,12);

Generated 20:01:47 on Oct 28, 2020