Hello I'm regular expression newbie in PHP
I'm try sort out a sting that I can insert data to MySQL which field is "timestamp"
$string1 = "7/1/2015, 19:42:52";
$string2 = "12/12/2015, 1:08:17";
$string1 = preg_replace("/\//",'-',$string);
$string2 = preg_replace("/\//",'-',$string);
this step will like:
7-1-2015, 19:42:52
12-12-2015, 1:08:17
if I wnat sort out (include ZEROFILL) sting like:
string1 = 2015-07-01 19:42:52
string2 = 2015-12-12 01:08:17
What Can I do..?
sprintf()
\b(\d)\b
replace with0\1
date_parse_from_format
to parse the original strings, thendate
to print them in the format that you want? This doesn't seem like an appropriate use for regular expressions.