Expand my Community achievements bar.

JavaScript :: Date & TIME

Avatar

Former Community Member
Hi,

I know this is elemental, but here goes:



Can somebody please give me some handy script/objects for DATE & TIME!

Example: Set a Date/Time field to the Date & TIME now! (Javascript only please)



Date.getDate()

now()

????
2 Replies

Avatar

Former Community Member
var d = new Date();

orderDate.rawValue = d.toString();

Avatar

Former Community Member
For my peeps...



JAVASCRIPT



var d, s;



s = "";

d = new Date();



s += "" + d.getFullYear() + "/";

s += "" + zeroPad(d.getMonth() + 1) + "/";

s += "" + zeroPad(d.getDate());

s += " ";

s += "" + zeroPad(d.getHours()) + ":";

s += "" + zeroPad(d.getMinutes()) + ":";

s += "" + zeroPad(d.getSeconds());



this.rawValue = s;



var str;

function zeroPad(intVal)

{

str = "" + intVal;

if (intVal < 10)

{

str = "0" + intVal;

}

return str;

}