Javascript time_sleep_until : Miscellaneous Functions : PHP functions in JavaScript JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » PHP functions in JavaScript » Miscellaneous Functions »

 

Javascript time_sleep_until


Make the script sleep until the specified time
Example 1

Running
1.time_sleep_until(1233146501) // delays until the time indicated by the given timestamp is reached

Could return
1.true
function time_sleep_until(timestamp) {
    // Make the script sleep until the specified time  
    // 
    // version: 902.210
    // discuss at: http://phpjs.org/functions/time_sleep_until
    // +   original by: Brett Zamir
    // %          note: For study purposes. Current implementation could lock up the user's browser.
    // %          note: Expects a timestamp in seconds, so DO NOT pass in a JavaScript timestamp which are in milliseconds (e.g., new Date()) or otherwise the function will lock up the browser 1000 times longer than probably intended.
    // %          note: Consider using setTimeout() instead.
    // *     example 1: time_sleep_until(1233146501) // delays until the time indicated by the given timestamp is reached
    // *     returns 1: true
    while (new Date() < timestamp*1000);
    return true;
}


HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo PHP functions in JavaScript
» Miscellaneous Functions