Revision: 36314
Updated Code
at November 20, 2010 10:32 by chrisaiv
Updated Code
/*
Internet Timestamp Generator
Copyright (c) 2009 Sebastiaan Deckers
License: GNU General Public License version 3 or later
*/
var Timestamp = {
start: function (date){
date = date ? date : new Date();
var offset = date.getTimezoneOffset();
return this.pad(date.getFullYear(), 4)
+ "-" + this.pad(date.getMonth() + 1, 2)
+ "-" + this.pad(date.getDate(), 2)
+ "T" + this.pad(date.getHours(), 2)
+ ":" + this.pad(date.getMinutes(), 2)
+ ":" + this.pad(date.getSeconds(), 2)
+ "." + this.pad(date.getMilliseconds(), 3)
+ (offset > 0 ? "-" : "+")
+ this.pad(Math.floor(Math.abs(offset) / 60), 2)
+ ":" + this.pad(Math.abs(offset) % 60, 2);
},
pad: function (amount, width ){
var padding = "";
while (padding.length < width - 1 && amount < Math.pow(10, width - padding.length - 1))
padding += "0";
return padding + amount.toString();
}
}
console.log( Timestamp.start() );
Revision: 36313
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 20, 2010 10:32 by chrisaiv
Initial Code
<script charset="utf-8" type="text/javascript">
/*
Internet Timestamp Generator
Copyright (c) 2009 Sebastiaan Deckers
License: GNU General Public License version 3 or later
*/
var Timestamp = {
start: function (date){
date = date ? date : new Date();
var offset = date.getTimezoneOffset();
return this.pad(date.getFullYear(), 4)
+ "-" + this.pad(date.getMonth() + 1, 2)
+ "-" + this.pad(date.getDate(), 2)
+ "T" + this.pad(date.getHours(), 2)
+ ":" + this.pad(date.getMinutes(), 2)
+ ":" + this.pad(date.getSeconds(), 2)
+ "." + this.pad(date.getMilliseconds(), 3)
+ (offset > 0 ? "-" : "+")
+ this.pad(Math.floor(Math.abs(offset) / 60), 2)
+ ":" + this.pad(Math.abs(offset) % 60, 2);
},
pad: function (amount, width ){
var padding = "";
while (padding.length < width - 1 && amount < Math.pow(10, width - padding.length - 1))
padding += "0";
return padding + amount.toString();
}
}
console.log( Timestamp.start() );
Initial URL
http://cbas.pandion.im/2009/10/generating-rfc-3339-timestamps-in.html
Initial Description
I needed a way to talk to Google Calendars. here's how I was able to create a RFC 3339 timestamp
Initial Title
Javascript: Creating a Google Calendar RF3339 Timestamp
Initial Tags
javascript
Initial Language
JavaScript