More About Sortable Dates; Plus AutoHotKey Scripts! Writer #1, 2024-08-112024-08-11 As mentioned in my other post Date/Time Formatting Can Unite The World, dates and times should be formatted in a very specific way. They are either ordered from general to specific, or you just have a jumbled mess. Sorry, Europe, but your dd-mm-yyyy is ridiculous and completely reversed. When you give the time do you say “35 seconds past the 10th minute of 9 o’clock PM”? No, of course you don’t, because the smaller segments of time have no meaning until the larger segments provide the context. That is why I believe in putting the hour designation (AM and PM) before the hour, not after the seconds. The rule should be “largest to smallest”. This not only makes sense from a logical perspective, but when you’re using a computer (which is pretty much always) and you want to write a date in a sortable fashion, then you must use “largest to smallest”. Furthermore, you must always use the same number of digits for each block, ie not just 2 but 02. Recently, I updated my code to reflect a very important change. Something I overlooked at first. Now, it is handled correctly. The noon hour cannot be “12”, it must be “00”. So, now it works. For example, “PM 00:30” is what you know as “12:30 PM”. It’s not much of a jump since interpreting “00” as “12 midnight” is natural when using the 24-hour clock. In my proposed system, it would simply be “AM 00:00” to mean midnight and “PM 00:00” to refer to noon. Pretty simple, really. And sortable. AutoHotKey is the perfect tool to generate the current date and time while adhering to the logical date and time standard laid out on this site. After seeing my shortcuts and naming conventions, you might notice the influence I received from my past. The habit of ctrl + ; to get the date comes from Excel. The term dts, short for “date timestamp” comes from my Palm Pilot days. Anyway, using AutoHotKey, here are the functions that will generate the right date and time: GetSortableDate(){ FormatTime, DateString, R, yyyy-MM-dd return DateString } GetSortableTime(){ paddedHour := Format("{:02}", Mod(A_Hour,12)) min := A_Min sec := A_Sec FormatTime, ampm, R, tt TimeString = %ampm% %paddedHour%:%min%:%sec% return TimeString } GetSortableDTS(){ date = % GetSortableDate() time = % GetSortableTime() datetime = %date% %time% return datetime } Notice the new “Mod” function, which runs the “modulus” function on the hour. I was happy to figure out that the modulus of the hour turns 12 and 24 into zero while keeping the other hours the same. Perfect! Opinion Technology autohotkeydate formattingdatestimestimestamp