if I use date('Y-m-d H:i:s.u')
the output will be some thing like 2015-11-03 13:25:25.253000. But i need 2015-11-03 13:25:25.253 how I can do it?
Asked
Active
Viewed 1,434 times
0

Kalim
- 347
- 1
- 7
- 17
-
1[So you can't find a PHP function that will cut the last three characters from a string?](http://php.net/manual/en/function.substr.php) – Mark Baker Nov 03 '15 at 08:34
-
You don't get `2015-11-03 13:25:25.253000`. You get `2015-11-03 13:25:25.000000` – Daniel Alder Nov 03 '15 at 08:37
1 Answers
0
Try this date('Y-m-d H:i:s'.substr((string)microtime(), 1, 4))
or what Daniel suggests in the comment down below.

link1tmk
- 1
- 1
-
1Just for good style: you shouldn't include variable content in the format string. use `date('Y-m-d H:i:s').substr((string)microtime(), 1, 4)` instead - maybe there is once an optimizer which compiles/caches the format in advance. this will fail with variable strings – Daniel Alder Nov 03 '15 at 08:38
-