![]() Also, you can use the format() method, but be careful, this method returns a string: Carbon::now()->format("Uu") Just create a new Carbon instance and get the timestamp in milliseconds: Carbon::now()->getTimestampMs() ![]() If you use any framework with the Carbon package installed, you can use it to measure time. Just multiply it by the required multiplier: hrtime(true) * 1000 //microseconds You can easily convert the time in nanoseconds to milliseconds or microseconds. You can measure the execution time in nanoseconds using this code: $start = hrtime(true) If you pass true as the first argument, you will get an integer with the quantity of nanoseconds: hrtime(true) By default it will return an array where the first element contains seconds and the second contains nanoseconds: hrtime() The hrtime() accepts a boolean as the first argument, which allows determining whether it should return an array or an integer. It is not a Unix timestamp, so you can use it only during the current program execution, and you should not save it in the database or somewhere else. Note that the function returns high-resolution time, counted from an arbitrary point in time.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |