3 ms·
The TimeClass:relative() function is a bit nasty, how many times do you need to calculate date('d/m/Y', $time) ?!. [edit] Or, time() for that matter, in fact t
by pillock 14y ago
The TimeClass:relative() function is a bit nasty, how many times do you need to calculate date('d/m/Y', $time) ?!.
[edit]
Or, time() for that matter, in fact this could be a subtle bug, as the return value of time() may vary throughout the function (unlikely, I know!)
- shdon 14y agoSubtle and hard to trace bugs, yes. Can also happen if time() is used several times in a request, but in different functions. I've taken to preferring $_SERVER['REQUEST_TIME'] in most cases.
- mark_story 14y agoIf you're spending a few seconds rendering HTML, you probably have other big problems to solve above optimizing around time().
- shdon 14y agoThat's the thing. You don't have to. Two subsequent SQL INSERTs may occur only microseconds apart, but the result may still differ by a second, causing a problem with datetime. And it's horribly naieve to think every request always completes in a few milliseconds. There are plenty of good reasons a request may take a longer time. From overloaded servers to network congestion to long running cronjobs or other processes.
- mark_story 14y agoDepending on the situation you would want database inserts to reflect the passage of time, and not always stick to a 'start of request/job' time. I can see the desire of the parent to want to have all the HTML generated with the same understanding of time, but as a general practice I still think its a bad one to fix time.