IHYPRESS.NET
RUBY
HOME | ASP | C | CSS | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
Ruby (CGI Programming) ❯ Time and Date
<18>
#!/usr/bin/ruby puts "Content-type: text/html\n\n" puts "<pre style='font-size:15px;color:blue;'>" time = Time.new # or Time.now puts "Current Time : " + time.inspect puts time.year # Year puts time.month # Month(1 to 12) puts time.day # Day (1 to 31 ) puts time.wday # Day of week: 0 is Sunday puts time.yday # Day of year (1 to 366) puts time.hour # 24-hour clock puts time.min # Minutes (0 to 59) puts time.sec # Seconds (0 to 59) puts time.usec # Microseconds puts time.zone # Timezone name millenium = Time.local(2000, 1, 1, 0, 0) puts "Millenium Begins : " + millenium.inspect puts time.utc_offset # Offset from GMT puts time.isdst # false: If no DST. puts time.gmtime # Convert back to GMT. puts time.getlocal # New Time object in local zone puts time.getutc # New Time object in GMT puts time.strftime("%m/%d/%Y %H:%M:%S") puts "</pre>"
Current Time : 2024-05-06 20:58:39 -0500
2024
5
6
1
127
20
58
39
469911
CDT
Millenium Begins : 2000-01-01 00:00:00 -0600
-18000
true
2024-05-07 01:58:39 UTC
2024-05-06 20:58:39 -0500
2024-05-07 01:58:39 UTC
05/07/2024 01:58:39
COPYRIGHT © 2015-2024 IHYPRESS.NET. A DIVISION OF IHY PRESS. ALL RIGHTS RESERVED.