What's the time, chap?

Bash, 39 33 bytes

date "+It's %I:%M%P."|sed s/m/.m/

Wasted a bunch of chars because the spec requires a.m. or p.m. while date outputs am or pm. Thanks to @DigitalTrauma for saving 6 bytes!

This might not be very portable. It works on Ubuntu 15.04.

A solution that uses essentially the same method in Ruby, which is surprisingly the exact same length:

Ruby, 39 bytes

$><<`date "+It's %I:%M%P"`[0..-3]+'.m.'

AppleScript, 198

Because AppleScript. Because why not:

set AppleScript's text item delimiters to {":"," "}
set d to (current date)'s time string's every text item
"It's "&d's item 1&":"&d's item 2&string id ((d's item 4's first character's id)+32)&".m."

That was painful.


PHP, 35 33 bytes

Using the wrong tool for the job!

It's <?=trim(date('h:ia'),m)?>.m.

It simply removes the m at the end of am or pm, to allow to add the dots. The date comes as 00:00am, and with trim it becomes 00:00a.


Old answer (PHP 5.4+ only):

It's <?=date('h:i'),date(a)[0]?>.m.

This works because you can de-reference a value returned from a function. This isn't possible in PHP5.3 or older.

Tags:

Date

Code Golf