|
|
Browse by Tags
All Tags » DateTime
-
How Can I Separate The Month From the Year in a Date String Like 122007?
[datetime]::ParseExact(122007,'Myyyy',$null) | ft Month,Year
You can see you can use ParseExact to convert a custom format to d dateTime OBject from there it is simple of course
PS> [datetime]::ParseExact(122007,'Myyyy',$null)
zaterdag 1 december 2007 ...
-
This time not a translation from a Hey scriptingguy article, but a question that just came up in the #powerShell IRC channel,
how to convert a Unix timestamp to a local datetime ?
A Unix Timestamp is expressed in seconds since 1 January 1970 in UTC time, this function will convert the unix timestamp to a UTC time first, ...
-
# Level 15
(1..99 |% {''1${_}6''} |? {[datetime]::IsleapYear($_)} |? {([datetime]''01/26/$_'').dayofweek -eq 'Monday'} )[-2]
Enjoy,
Greetings /\/\o\/\/
-
As we are running for a new year again,Some more timeZone fun, I did a WMI example here : Hey PowerShell Guy!, How Can I Retrieve Time Zone Information for a Computer? , now I show an example that shows the given date in all timezones with information about the Daylight saving time.
This time I'm using the .NET framework 3.5 TimeZoneInfo ...
-
I Paste the following into the Consolewindow :
switch (get-date -Format tt) { 'AM' {'It is morning time.'} 'PM' {'It is afternoon/evening time.'}}
A variation on the Hey Scripting Guy article : How Can I Tell If a Time Occurred in the Morning or the Evening?
PS C:\scripts> switch (get-date -Format tt) ...
-
The Chat did go on while I made Last blog entry PowerShell : the power of REPL, -WhatIf and ScriptBlocks as Parameter when moving files :
[22:29] <generalhan> ok now time to work on something a bit harder ! ...[22:29] <generalhan> i have to move files based on date now too !
[22:31] <generalhan> so i have a ...
-
And another Hey, Scripting Guy ! translation to powerShell How Can I Get the Uptime of a Service?
The PowerShell translation :
$s = gwmi win32_service -filter ''name = 'spooler'''
''{0}'' -f ((get-date) - ([wmi]'').ConvertToDateTime((gwmi Win32_Process -filter ''ProcessID = '$($s.ProcessId)''').CreationDate))
I do output the Uptime in ...
-
Scripting games are over, but if you want some more PowerShell execersises , the rest of the scriptcenter including VbScript content might be usefull also.
As you might know, I also like to translate Hey Scripting Guy questions to PowerShell
(For a list of former Hey Scripting Guy translations on this blog and my ...
-
List 100 sumday's after 1-1-2000 (See : 2007 Winter Scripting Games Program page 17 and 23 )
My PoSH solution :
$sumdays = 0 $dt = [datetime]'2000-1-1' while ($sumdays -lt 100 ) { $dt = $dt.AddDays(1) ...
|
|
|