Is there any easy script that will take current datetime and convert to CEST and account for DST also? I want to use that in my file name
to help identify when process was ran.
Thanks
July 12, 2022 at 6:27 am
#using Powershell
Get-Date -UFormat "%A %B/%d/%Y %T %Z"
$Time = Get-Date
$Time.ToUniversalTime()
#Using .Net
[System.TimeZoneInfo]::GetSystemTimeZones( )
[System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId( (Get-Date), 'Greenwich Standard Time')
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
July 12, 2022 at 12:59 pm
Thanks..
$Date = Get-Date
$TimeZone = Get-TimeZone -Id "Central Europe Standard Time"
$OtherDate = [System.TimeZoneInfo]::ConvertTime( $Date, $TimeZone )
$OtherDate
How do I format $OtherDate into the file name, and also account for DST in my example?
Example output needed..
Job_Runs_2022-06-29T15-00-16
$Filename = $('Job_Runs_{0}.log' -f (get-date($OtherDate) -Format 'yyyy-MM-ddTHH-mm-ss'))
$Filename
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy