Soutenez Time.now : Rejoignez notre Plan Premium pour une expérience sans publicité ! Soutenez-nous : Passez Premium sans pub !
Backend Guide

Ruby World Time Integration

Ruby developers (especially in Rails) often deal with complex timezone configurations. Sometimes it is easier to query an external atomic clock API than to rely on the server's system time, especially in containerized environments.

RUBY
require 'net/http'
    require 'json'
    require 'uri'

    def fetch_time(zone)
      uri = URI("https://time.now/developer/api/timezone/#{zone}")
      response = Net::HTTP.get(uri)
      data = JSON.parse(response)
  
      puts "Time in #{data['timezone']}: #{data['datetime']}"
      puts "UTC Offset: #{data['utc_offset']}"
    end

    fetch_time('Europe/Berlin')

Why use Time.Now for Backend?

  • Standard Library only (No Gems)
  • Parses automatically to Hash
  • Clean syntax
API Reference Voir tous les guides