Sign in to follow this  
Followers 0
rickd

Non standard date format?

6 posts in this topic

Hi,

Is it possible to get the current date/time into the format "9.20pm Thu 21" using the build-in date/time functions?

Share this post


Link to post
Share on other sites



Yes.

...and now I suppose that you want to know how :-)

Take a look at _DateTimeSplit

then parse it via the string functions

then concatenate as desired...MSP


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thanks, I couldn't find anything in help about getting the day though, is that possible?

Share this post


Link to post
Share on other sites

Thanks, I couldn't find anything in help about getting the day though, is that possible?

@MDAY and @WDAY


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

@MDAY and @WDAY

Thanks, I had a go at getting the date/time into the format I want, this is the code.. is this the best way to do it? Or someone has a more efficient solution?

#Include <Date.au3> 

Local $numericday = @WDAY 
Local $numericdate = @MDAY 
Local $time = _NowTime(3) 
Local $ampm 
Local $datesting 

If $numericday = 1 Then 
        $textday = "Sun" 
ElseIf $numericday = 2 Then 
        $textday = "Mon" 
ElseIf $numericday = 3 Then 
        $textday = "Tue" 
ElseIf $numericday = 4 Then 
        $textday = "Wed" 
ElseIf $numericday = 5 Then 
        $textday = "Thur" 
ElseIf $numericday = 6 Then 
        $textday = "Fri" 
ElseIf $numericday = 7 Then 
        $textday = "Sat" 
EndIf 

If StringInStr($time, "a.m.", 0, 1) <> 0 Then 
        $ampm = "am" 
ElseIf StringInStr($time, "p.m.", 0, 1) <> 0 Then 
        $ampm = "pm" 
EndIf 

$time = StringTrimRight($time, 8) 

$datestring = $time & $ampm & " " & $textday & " " & $numericdate 

;Display the resulting time/date string 
msgbox(1,"",$datestring)

Share this post


Link to post
Share on other sites

Can't you just do

if @hour > 11 then
$ampm = "PM"
else
$ampm = "AM"
endif

msgbox(1, "", _NowTime(3) & $ampm & " " & StringLeft(_DateDayOfWeek, 3) & " " & @MDAY)

of course then Thursday is going to be displayed as Thu instead of Thur


My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0