Timestamp only for time

Hi,

Probably its not difficult to create but can anyone help me to create snippet for 24H Time stamp only

1 Like
// #popclip
// { name: Time, requirements: [paste], after: paste-result, lang: js }
return new Date().toLocaleTimeString();

(The above block is an extension snippet — select it then click “Install Extension” in PopClip.)

And you can control the exact format by proving parameters to toLocaleTimeString().

Thank You !

I’m now in EU and how to convert time to switch to 24H format ?

I will use 24hr format if your system locale is set to a European country in System Settings. But it’s still morning. Try it in a couple of hours :slight_smile:

After chaning region setting you have to quit and restart PopClip for it to take effect.

what interesting is, the Timestamp itself uses 24H format but only time stamp you/we created still shows as AM/PM
Why ?
Screenshot 2023-09-16 at 20.36.24

I don’t know. It’s pasting in 24h time for me
17:40:14

Did you restart PopClip?

Im on 17 Developer Beta and maybe this is a problem ?

It looks like your Timestamp extension is set to “International” which always uses 24hr anyway. So system setting has not propagated to PopClip somehow.

any other way to force Popclip use 24H beside system setting ?

Not for the “locale” JS functions. Could rewrite the JavaScript snippet in this thread to do it though, by hard coding the format.

What Region do you have your system set to?

You didn’t answer my question yet if you restarted PopClip…

of course I restarted … Region is Georgia

Thanks. When I ask a question it’s because I want to know the answer, because that answer will help me understand what is happening.

Try this:

// #popclip
// { name: Time, requirements: [paste], after: paste-result, lang: js }
const tfOptions = {
  hour: '2-digit',
  minute: '2-digit',
  second: '2-digit'
};
return new Intl.DateTimeFormat(['ka-GE'], tfOptions).format(new Date());

Great now it works ! Thank you so much for your help and thanks for creating such an Amazing Application !

1 Like