php - preg_replace all decimals over 3 digitsGet the solution ↓↓↓
You don't need regex.
Use the date_create_from and transform the string to a new datetime.
$date = date_create_from_format('Y-m-d H:i:s\.u', '2018-01-01 12:20:23.123000'); echo date_format($date, 'Y-m-d H:i:s\.v'); // 2018-01-01 12:20:23.123
u is microseconds (1-6 digits).
v is milliseconds (3 digits).
Share solution ↓
Link To Answer People are also looking for solutions of the problem: ftp_put(): can't open that file: no such file or directory
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.