Last active
December 17, 2015 18:59
-
-
Save cleytonferrari/5656850 to your computer and use it in GitHub Desktop.
TimeZone em C#, uma forma simples de utilizar time zones em C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace TimeZone | |
{ | |
class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
Console.WriteLine("Data/Hora atual UTC : {0}", DateTime.UtcNow.ToString("dd/MM/yyyy HH:mm:ss")); | |
Console.WriteLine("Data/Hora (UTC -4 Rondônia) : {0}", DateTime.UtcNow.AddHours(-4).ToString("dd/MM/yyyy HH:mm:ss")); | |
Console.WriteLine("Data/Hora (UTC -3 Brasilia) : {0}", DateTime.UtcNow.AddHours(-3).ToString("dd/MM/yyyy HH:mm:ss")); | |
Console.WriteLine("Data/Hora (UTC +8 Pequim ) : {0}", DateTime.UtcNow.AddHours(+8).ToString("dd/MM/yyyy HH:mm:ss")); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Referencias:
http://msdn.microsoft.com/pt-br/library/system.datetime.utcnow.aspx
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx