Get date and time on the same line

command-line, powershell

Solution

Try the following (PowerShell):

Get-Date -Format G

27.11.2013 17:10:23

The format is defined with the system's regional settings, so for me this is what I get, but if you're regional date/time format is what you want, it should show up like you want.

(Get-Date).ToString()

would probably also work.

UPDATE:

"Date and time is: $((Get-Date).ToString())"

Problem

I can use `date /t` and `time /t` to get the date and time, but it doesn't display it next to each other. I wanted to make it do that and display like this: ``` Current Date & Time ------------------- 11/27/2013 10:43:05 AM ```

Original source