bcparanj@gmail.com
8/22/2008 8:42:00 AM
How do I extract the hour and minutes in UTC from a DateTime object? I
have looked at the Ruby cookbook and Ruby Way with no luck.
When I try:
>> d = DateTime.new(2008,8, 20, 12, 15)
=> Wed, 20 Aug 2008 12:15:00 +0000
>> d.zone
=> "+00:00"
>> d.min
=> 15
>> d.hour
=> 12
The result is not the same as executing the following javascript:
// Converts the given time into UTC, returns this in a string
function getUTCDateString(y,m,d,h,min) {
var timeObj = new Date(y,m-1,d,h,min);
var dateStr = "" + timeObj.getUTCFullYear();
dateStr += stringPad(timeObj.getUTCMonth()+1);
dateStr += stringPad(timeObj.getUTCDate());
dateStr += "T" + stringPad(timeObj.getUTCHours());
dateStr += stringPad(timeObj.getUTCMinutes()) + "00Z";
return dateStr;
}
TIA.