Ruby | Time xmlschema function Last Updated : 07 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Time#xmlschema() : xmlschema() is a Time class method which returns the string which represents the time as a dateTime defined by XML Schema. Format : CCYY-MM-DDThh:mm:ssTZD CCYY-MM-DDThh:mm:ss.sssTZD Syntax: Time.xmlschema() Parameter: Time values Return: the time as a dateTime defined by XML Schema Example #1 : Ruby # Ruby code for Time.xmlschema() method # loading library require 'time' # declaring time a = Time.new(2019) # declaring time b = Time.new(2019, 10) # declaring time c = Time.new(2019, 12, 31) # Time puts "Time a : #{a}\n\n" puts "Time b : #{b}\n\n" puts "Time c : #{c}\n\n\n\n" # xmlschema form puts "Time a xmlschema form : #{a.xmlschema}\n\n" puts "Time b xmlschema form : #{b.xmlschema}\n\n" puts "Time c xmlschema form : #{c.xmlschema}\n\n" Output : Time a : 2019-01-01 00:00:00 +0000 Time b : 2019-10-01 00:00:00 +0000 Time c : 2019-12-31 00:00:00 +0000 Time a xmlschema form : 2019-01-01T00:00:00+00:00 Time b xmlschema form : 2019-10-01T00:00:00+00:00 Time c xmlschema form : 2019-12-31T00:00:00+00:00 Example #2 : Ruby # Ruby code for Time.xmlschema() method # loading library require 'time' # declaring time a = Time.now # declaring time b = Time.new(1000, 10, 10) # declaring time c = Time.new(2020, 12) # Time puts "Time a : #{a}\n\n" puts "Time b : #{b}\n\n" puts "Time c : #{c}\n\n\n\n" # xmlschema form puts "Time a xmlschema form : #{a.xmlschema}\n\n" puts "Time b xmlschema form : #{b.xmlschema}\n\n" puts "Time c xmlschema form : #{c.xmlschema}\n\n" Output : Time a : 2019-08-27 09:41:32 +0000 Time b : 1000-10-10 00:00:00 +0000 Time c : 2020-12-01 00:00:00 +0000 Time a xmlschema form : 2019-08-27T09:41:32+00:00 Time b xmlschema form : 1000-10-10T00:00:00+00:00 Time c xmlschema form : 2020-12-01T00:00:00+00:00 Comment More infoAdvertise with us Next Article Ruby | Time usec function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Time-class Similar Reads Ruby | Time usec function Time#usec() is a Time class method which returns the number of microseconds for time. Syntax: Time.usec() Parameter: Time values Return: the number of microseconds for time. Example #1 : Ruby # Ruby code for Time.usec() method # loading library require 'time' # declaring time a = Time.new(2019) # de 2 min read Ruby | Time year() function Time#year() : year() is a Time class method which returns the year for time (including the century). Syntax: Time.year() Parameter: Time values Return: year for time (including the century). Example #1 : Ruby # Ruby code for Time.year() method # loading library require 'time' # declaring time a = Ti 2 min read Ruby | Time year() function The year() is an inbuilt method in Ruby returns the year for time Syntax: time.year() Parameters: The function accepts no parameter Return Value: It returns the year for time Example 1: CPP # Ruby code for year() method # Include Time require 'time' # Declaring time a = Time.new(2000, 12, 23) # Prin 1 min read Ruby | Time utc function Time#utc() : utc() is a Time class method which returns the conversion of time to UTC (GMT), modifying the receiver. Syntax: Time.utc() Parameter: Time values Return: the conversion of time to UTC (GMT), modifying the receiver. Example #1 : Ruby # Ruby code for Time.utc() method # loading library re 2 min read Ruby | Time utc? function Time#utc?() : utc?() is a Time class method which checks whether the time is a conversion to UTC (GMT), modifying the receiver. Syntax: Time.utc?() Parameter: Time values Return: true - if there is a time conversion to UTC (GMT), modifying the receiver Otherwise return false. Example #1 : Ruby # Rub 2 min read Ruby | Time to_time function Time#to_time() : to_time() is a Time class method which returns the time object itself. Syntax: Time.to_time() Parameter: Time values Return: the time object itself. Example #1 : Ruby # Ruby code for Time.to_time() method # loading library require 'time' # declaring time a = Time.new(2019) # declari 2 min read Like