IHYPRESS PROGRAMMING
CGI/Ruby programs with code and output for beginners
Ruby logo
HOME | ASP | C | CSS | GNUPLOT | 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>"
Hergestellt in Deutschland / Made in Germany
Current Time : 2025-04-02 00:44:59 -0500
2025
4
2
3
92
0
44
59
427967
CDT
Millenium Begins : 2000-01-01 00:00:00 -0600
-18000
true
2025-04-02 05:44:59 UTC
2025-04-02 00:44:59 -0500
2025-04-02 05:44:59 UTC
04/02/2025 05:44:59
COPYRIGHT © 2015-2025 IHY PRESS Frankfurt am Main 60329 Deutschland