UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

98 lines (74 loc) 2.44 kB
<!-- Generated by Rakefile:build --> <strong> OMA </strong> on 2010-07-14 15:48:46 <br /> Sorry, I think I messed up the example timestamps in my previous posts, but the accuracy problem remains... <hr /> <strong> OMA </strong> on 2010-07-14 15:23:52 <br /> Just to let you know the getTime function is pretty innacurate in Fresco (a browser used in some devices such as TV set top boxes). For example, the date 2011/03/03 22:59:00, when converted in Firefox is correctly translated to 1301864340, but in Fresco, it gets translated to 1301871540, which is really 2011/04/03 17:59:00 (a month off!). So maybe, for accuracy's sake in all browsers, the date to timestamp conversion should be done manually instead of relying in getTime() <hr /> <strong> Nuked </strong> on 2010-07-08 18:50:14 <br /> Just to say thanks. <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2009-11-29 23:38:19 <br /> Thanks Jawad, that's always nice to hear! <hr /> <strong> <a href="http://jawadonweb.com" rel="nofollow">Jawad Shuaib</a> </strong> on 2009-11-24 16:59:56 <br /> I love you guys, PHP.js has vastly improved my ability to ship code fast. <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2009-09-04 19:06:12 <br /> @ HKM: Thanks for supplying the fix! Will be online shortly. Until then review at: http://github.com/kvz/phpjs/commit/459b16b6d454d4e30386729ee2640d0013449578 <hr /> <strong> HKM </strong> on 2009-09-04 17:40:29 <br /> It have 1 second error because the milliseconds will be counded. Therefore, the code should be changed to that. <pre><code> function time () { return Math.floor(new Date().getTime()/1000); } </code></pre> <hr /> <strong> <a href="http://bahai-library.com" rel="nofollow">Brett Zamir</a> </strong> on 2009-03-13 16:33:10 <br /> For the record, I thought I'd try returning &quot;Date.parse(new Date())/1000;&quot; which is technically shorter, but it turns out quite a bit slower (parsing time I guess) <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-08-27 16:35:02 <br /> @ metjay: fair enough, thank you! <hr /> <strong> metjay </strong> on 2008-07-28 19:47:20 <br /> This goes even shorter: <pre><code> function time() { return Math.round(new Date().getTime()/1000); } </code></pre> <hr />