Created
          January 18, 2013 16:52 
        
      - 
      
- 
        Save icodejs/4566009 to your computer and use it in GitHub Desktop. 
    Get UTC time
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function _getUtcTime () { | |
| var | |
| d = date, | |
| i = 0, | |
| arr, | |
| t; | |
| d = d || new Date(); // default to now | |
| arr = [ | |
| d.getUTCFullYear(), | |
| d.getUTCMonth(), | |
| d.getUTCDate(), | |
| d.getUTCHours(), | |
| d.getUTCMinutes(), | |
| d.getUTCSeconds() | |
| ], | |
| arr[1] += 1; // incrememt month by 1 | |
| while (i++ < 7) { | |
| t = arr[i]; | |
| if (t < 10) { | |
| arr[i] = '0' + t; // pad with 0 | |
| } | |
| } | |
| return arr.splice(0, 3).join('-') + 'T' + arr.join(':'); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment