简体   繁体   English

Get-Date -Format给Get-Date提供了不同的结果

[英]Get-Date -Format is giving different result to Get-Date

I am getting date and time in a variable which is different from my Server clock. 我在一个与我的服务器时钟不同的变量中获取日期和时间。

QDate = $(Get-Date -Format "yyyyMMdd hh:MM:ss tt")

If I simply type Get-Date I can get the server local time but I am using this variable to insert time in SQL Database and I need the dates in given format. 如果我只是键入Get-Date我可以获取服务器本地时间,但我使用此变量在SQL数据库中插入时间,我需要给定格式的日期。

> Get-Date -Format "yyyyMMdd hh:MM:ss tt" 
20190425 10:04:39

> Get-Date
April 25, 2019 10:07:28 AM

time difference 04 minutes 时差04分钟

You've got... 你有...

Get-Date -Format "yyyyMMdd hh:MM:ss tt" 

You want... 你要...

Get-Date -Format "yyyyMMdd hh:mm:ss tt"

Note, the change in case of the "mm" for minutes, 注意,“mm”表示分钟的变化,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM