/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" Working with a Path in MSH "," MSH MSN Instant messenger project (broken off) "," Running (Un-block) a downloaded script in MSH "," Timing the loading of your profile in MSH "," Tuning MSH in your Profile "," Einstein 2 + subtopic. "," Burn MSH ?? "," Monad and Adam (and a preview of my to-be AD provi... "," Windows MineSweeper cheat "," erroraction on new-item, my Wrong use of Stringbui... "," ")

Monday, November 28, 2005

 


MSH get-dateFormat function



I very handy function to get the current datetime Formats,
(finaly an end to all those trips to the controlpanel )


Function get-DateFormat{[System.Globalization.CultureInfo]::CurrentCulture.DateTimeFormat | select *Pattern}



I found the tip here : James Manning's blog,
What formats can I specify for date/time with the tf.exe command-line?

thank's alot that's another one for my toolbox ;-)


MSH>get-dateformat


FullDateTimePattern : dddd, MMMM dd, yyyy h:mm:ss tt
LongDatePattern : dddd, MMMM dd, yyyy
LongTimePattern : h:mm:ss tt
MonthDayPattern : MMMM dd
RFC1123Pattern : ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
ShortDatePattern : M/d/yyyy
ShortTimePattern : h:mm tt
SortableDateTimePattern : yyyy'-'MM'-'dd'T'HH':'mm':'ss
UniversalSortableDateTimePattern : yyyy'-'MM'-'dd HH':'mm':'ss'Z'
YearMonthPattern : MMMM, yyyy


Also, as we are at dateformats now,
A nice one to try also :



(get-date).GetDateTimeFormats()


Pick one ;-)

*edit* as I just posted this I did think about that last command, and did think there should be a more "native" way to do this , and Yes ;-)

MSH>(get-UICulture).get_DateTimeFormat()


AMDesignator : AM
Calendar : System.Globalization.GregorianCalendar
DateSeparator : /
FirstDayOfWeek : Sunday
CalendarWeekRule : FirstDay
FullDateTimePattern : dddd, MMMM dd, yyyy h:mm:ss tt
LongDatePattern : dddd, MMMM dd, yyyy
LongTimePattern : h:mm:ss tt
MonthDayPattern : MMMM dd
PMDesignator : PM
RFC1123Pattern : ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
ShortDatePattern : M/d/yyyy
ShortTimePattern : h:mm tt
SortableDateTimePattern : yyyy'-'MM'-'dd'T'HH':'mm':'ss
TimeSeparator : :
UniversalSortableDateTimePattern : yyyy'-'MM'-'dd HH':'mm':'ss'Z'
YearMonthPattern : MMMM, yyyy
AbbreviatedDayNames : {Sun, Mon, Tue, Wed, Thu, Fri, Sat}
ShortestDayNames : {Su, Mo, Tu, We, Th, Fr, Sa}
DayNames : {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}
AbbreviatedMonthNames : {Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, }
MonthNames : {January, February, March, April, May, June, July, August, September, October, November, December, }
IsReadOnly : True
NativeCalendarName : Gregorian Calendar
AbbreviatedMonthGenitiveNames : {Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec, }
MonthGenitiveNames : {January, February, March, April, May, June, July, August, September, October, November, December, }


gr /\/\o\/\/


Comments:
Anonymous Anonymous
Here's some more fun you can have with cultures.

An easy way to cycle through all the cultures that Windows supports:

foreach ($culture in [System.Globalization.CultureInfo]::GetCultures([System.Globalization.CultureTypes]::InstalledWin32Cultures))
{
[System.Threading.Thread]::CurrentThread.CurrentCulture = $culture
"---------------------------------------"
$culture.EnglishName + " - " + $culture.LCID
"---------------------------------------"
[DateTime]::Now
}

Also, when you see methods called get_DateTimeFormat(), that is usually the underlying method behind a .Net property. So your example could also be written:

(get-UICulture).DateTimeFormat
 
Blogger /\/\o\/\/
@ lee

(get-UICulture).DateTimeFormat

LOL, was waiting for that one

but I did not want to repost 2 times in 10 minutes ;-)

nice example, 2 bad there is no straight connection to the Timezone, otherwise you could output there local time ;-)

gr /\/\o\/\/

@ ls

PS timezone ofset info is found like this :
([timezone]::CurrentTimeZone).GetUtcOffset([dateTime]::now)

for daylight changes see also :
when to change your clock ? ask Monad !!
http://mow001.blogspot.com/2005/10/when-to-change-your-clock-ask-monad.html
 
Post a Comment



<< Home

Archives

October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006  

$Links = ("PowerShell RC1 Docs"," PowerShell RC1 X86"," PowerShell RC1 X64"," Monad GettingStarted guide"," Monad Progamming Guide"," Monad SDK"," Monad videos on Channel 9"," MSH Community Workspace"," scripts.readify.net "," MonadSource"," www.reskit.net"," PowerShell Blog"," Under The Stairs"," computerperformance powershell Home"," proudlyserving"," MSH on wikipedia"," MSHWiki Channel 9"," Keith Hill's Blog"," Precision Computing"," PowerShell for fun"," MSH Memo (Japanese)"," monadblog")

find-blog -about "PowerShell","Monad" | out-Technorati.
find-blog -contains "","" | out-Technorati.
Google
 
Web mow001.blogspot.com

This page is powered by Blogger. Isn't yours?