Space before Time from Action

Wondering if someone can help me out:

Each time I execute this action to place time into a draft a leading space is placed before a single-digit hour.

So, no space for 10:00, 11:00, 12:00.

How do I eliminate the leading space from this code:

[[date|%l:%M %p]]

Details on date formats can be found in the Using Templates article, including a link to the available formatters in Apple’s strftime implementation.

I don’t see an obvious option for getting the decimal hour without the leading blank, unfortunately.

If it’s a strong requirement, it could be done in script.

Is there an action that could run after it to remove the space?

Thanks for your help!

I’m so excited to be able to give a better answer than Greg that I’ve nearly peed my pants.

Try this:

[[date|%-I:%M %p]]

Apple’s strftime implementation includes the hyphen modifier, which suppresses the leading space.

2 Likes

I’m suspending your account @drdrang. :rofl:

Learn something new every day.

2 Likes

@drdrangn This achieved the desired result - thanks so much and kudos to you for the win!

1 Like