2 Replies Latest reply on Jul 15, 2013 5:10 AM by Val Palhories

    Convert a date to UTC

    Val Palhories

      Stupid question time ...

       

      current_date = Date.today

      tomorrow_date = Date.today + 1

       

      How do I convert both dates to their UTC equivalent for today at midnight and tomorrow at midnight?

       

      Thanks.

       

      --- Val

        • Re: Convert a date to UTC
          Kutir Mobility

          This is a ruby question.

          Would be easy for you if you can try it at Ruby forum or SOF.

           

          Visnupriya

          Kutir Mobility

            • Re: Convert a date to UTC
              Val Palhories

              Visnupriya,

               

              Good point. I did eventually get it figured out. For those that are looking for something similar this is how I got it done:

               

              def UTC_Today_Midnight()

                    current_date = Date.today

                    offset = Settings.GetUTCOffset

                    utc_today = Time.utc(current_date.year,current_date.month,current_date.day,offset.to_i.abs,0,0)

                    return utc_today

              end

               

              As with everything else I'm sure there are millions (well .. maybe not millions!) of other ways to get the same results. This worked for me.