C
C#2y ago
BlackBull

Need help getting cest timezone

i currently have this code
var timer = new PeriodicTimer(TimeSpan.FromSeconds(1));

while (await timer.WaitForNextTickAsync())
{
DateTime dateNow = DateTime.Now;
label5.Text = "The date and time are {0} UTC."+
TimeZoneInfo.ConvertTimeToUtc(dateNow);
string time = DateTime.Now.ToString("hh:mm");
}
var timer = new PeriodicTimer(TimeSpan.FromSeconds(1));

while (await timer.WaitForNextTickAsync())
{
DateTime dateNow = DateTime.Now;
label5.Text = "The date and time are {0} UTC."+
TimeZoneInfo.ConvertTimeToUtc(dateNow);
string time = DateTime.Now.ToString("hh:mm");
}
but this gets the time in utc i want to get the time cest who can help me out
2 Replies
ero
ero2y ago
looking online, it seems you're forced to just do DateTime.UtcNow.AddHours(2)
BlackBull
BlackBull2y ago
aah okey ill try that thanks that worked !