Date picker in request form returns wrong date
However, when I check the UserInput field, it is modified and stored as 2018-04-29 22:00:00 UTC". I need to add an SMA script in which I want to do something based on the date and there I'm also stuck with the wrong converted date.
Any ideas how I can get around this ? Obviously I want to work with the date that the end user selected.
Stephane
Best Answer
-
Adam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭System Center (and I truly do mean all of the products) store datetime in UTC format. When it comes to working with SCSM, PowerShell, SCO/SMA your best bet is to do a conversion from that UTC time to your respective local time zone. Take the following PowerShell example:
[datetime]$startDate = $utcStartDate [datetime]$endDate = $utcEndDate [datetime]$startDateTime = [System.TimeZone]::CurrentTimeZone.ToLocalTime($startDate) [datetime]$endDateTime = [System.TimeZone]::CurrentTimeZone.ToLocalTime($endDate) $startDateTime.ToString() $endDateTime.ToString()
In doing so you can let System Center keep on being System Center and still get what you need.7
Answers
In doing so you can let System Center keep on being System Center and still get what you need.
The UserInput field contains the correct data, but when it is run through the Get-SCSMWorkItemUserInput cmdlet the date is no longer correct. So I'll have to re-parse it from the original UserInput field on the SR.
Stephane
So to have a proper time in eg. Title field I need to create runbook ? Aren't there any easier way?