# Challenge

You must output the current time continuously (until cancelled by an interrupt), once every second, by any of the following means:

• It must be in 24-hour or AM/PM format.
• If it is the former, it must be spaced out with colons (i.e. 15:47:36).
• If it is the latter, it must be spaced out with colons and have the AM/PM following (i.e. 3:47:36 PM)
• It may be pulled from the internet.
• It may be the system time.
• It must output any naturally accessible form of output which supports text that you choose.
• Output may have extra information aside of the time in it, but you must guarantee one, and only one, output of time per second.
• The continuous output must be a second apart - if you choose to wait until the second changes between outputs, that is fine. If you wait a second between each output, that is perfectly acceptable, despite the eventual loss of accuracy.

Since this is a catalog, languages created after this challenge are allowed to compete. Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. Other than that, all the standard rules of must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8).

# Catalog

The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:

## [><>](http://esolangs.org/wiki/Fish), 121 bytes

• Does "until cancelled by an interrupt" include closing the program or does it need a mechanism to stop the cycle coded into it? – user81655 Nov 27 '15 at 23:00
• – Mego Nov 28 '15 at 6:21
• Warning: All sleep 1 based answer break rule 5: you must guarantee one, and only one, output of time per second. !! – F. Hauri May 17 '16 at 23:03
• F. Hauri: How so? Rule 6 says "If you wait a second between each output, that is fine as well." – YetiCGN Aug 26 '16 at 22:03
• @Jasen No, but the meaning of "that is fine" implies that the wait option is still valid, regardless of the eventual time loss. I have clarified this for you. – Addison Crump Jan 7 '17 at 19:07

# Minecraft 1.8.7, 7 + 8 = 15 blytes (bytes + blocks)

Only one command block involved:

xp 1 @p

Output goes to the client console like so:

As part of the normal output.

This is the system:

xp gives a specified amount of experience to a specified player with the syntax xp <amount> <player>. I'm pretty sure this is the smallest command that has singular output that I can get, now.

• Don't say "19 bytes" because you didn't measure your answer size in bytes. – feersum Nov 28 '15 at 0:00
• @feersum There's a reason for me saying bytes, trust me. This is the closest thing to a consensus for MC as of now. – Addison Crump Nov 28 '15 at 0:04
• You can use the deprecated number codes can't you? – Conor O'Brien Nov 28 '15 at 2:07
• Use this scoring system if you want, 19 whatevers, but it isn't 19 bytes, because there is no previously defined encoding that allows you to store this solution in a 19-byte file. – feersum Nov 28 '15 at 5:47
• @CᴏɴᴏʀO'Bʀɪᴇɴ I'd have to wrap it in JSON, I believe. Unless I used 1.6, but that's practically another language. – Addison Crump Nov 28 '15 at 11:00

# JavaScript, 32 bytes

Uses the fact that setInterval evaluates code. This is not recommended, but when was that a concern in code golf?

Date() returns the current time and date in a format like this (may vary per system).

Wed Jul 28 1993 14:39:07 GMT-0600 (PDT)
• Would setInterval(alert,1e3,Date()) work instead? – ETHproductions Dec 9 '15 at 18:24
• @ETHproductions It always shows the same time for me – ev3commander Dec 9 '15 at 21:28
• @ETHproductions in your example Date() will only be evaluated once when you create the interval – MMM Dec 14 '15 at 13:00

## sh (+ watch), 11 bytes

Script:

watch -n1 .

(no trailing newline)

Output:

Every 1,0s: . (SPACES) Sat Nov 28 19:07:51 2015

The amount of spaces depends on the terminal width.

Tested on Debian8 and NetBSD7.

• Right tool for the job, +1 – Addison Crump Nov 28 '15 at 18:13
• Wait, does this count as a programming language? Can you give me a link to an interpreter? – Addison Crump Nov 28 '15 at 18:34
• @VoteToClose watch is a coreutil. The real language is bash/sh. – Doorknob Nov 28 '15 at 18:35
• So... shouldn't this be Bash (distribution), not watch? @Doorknob – Addison Crump Nov 28 '15 at 18:37
• Hmm You have to use -p switch to not break the rule you must guarantee one, and only one, output of time per second.!! – F. Hauri May 17 '16 at 23:00

# Snap, 87 6 blocks

(Yes, I changed it in MS Paint because I was too lazy to make another screenshot. So what? At least it's readable.)
click the script to run
24-hour clock.

• I always love graphical programming languages. :D +1 – Addison Crump Nov 28 '15 at 14:27
• oh hey ev3! I know you from Snap/Scratch forums :P why do you need Snap instead of Scratch, exactly? – anOKsquirrel Nov 28 '15 at 14:43
• @anOKsquirrel Because I don't need to nest all those join blocks. – ev3commander Nov 28 '15 at 14:45
• Shouldn't that read 9:21:08? – Luke Nov 30 '15 at 14:06
• @Luke As shown by the TI-BASIC answer, the time without the leading zero in an output is fine. It is human readable and clear what the time is. – Addison Crump Nov 30 '15 at 19:48

## Python 2, 47 bytes

from time import*
while[sleep(1)]:print ctime()

No online link because ideone times out (huehuehue) before printing anything.

Thanks to @xsot for the while[sleep(1)] trick and the ctime trick.

Prints out the current date and time like so: Fri Nov 27 21:23:02 2015

• /me claps slowly at the pun. Very funny Mego. ;D – Addison Crump Nov 28 '15 at 0:15
• I've posted your solution for Python 3 – jfs Nov 30 '15 at 19:45
• sleep 1 based answer break rule 5: you must guarantee one, and only one, output of time per second. – F. Hauri May 17 '16 at 23:01
• @F.Hauri sleep 1 causes the current thread to sleep for exactly one second. It complies with the rules. – Mego May 18 '16 at 0:35
• @F.Hauri Considering that the challenge author himself uses the equivalent of sleep(1) in both his AppleScript solution and his Vitsy+bash solution, it's clearly acceptable. – Mego May 18 '16 at 6:38

# Perl, Command Line, 24 bytes

sleep(say)while$_=gmtime This must be run from the command line, as perl -E'sleep(say)while$_=gmtime' (on windows, use double quotes instead). The date will be output along with the time, which seems to be allowed.

## Perl, 25 bytes

sleep print$/.gmtime;do$0

In a scalar context, gmtime will return a string similar to Sat Nov 28 10:23:05 2015. The result from print, always 1, is used as the parameter for sleep. do$0 is used to execute the script again, after the timer has finished. • As evidenced by @VoteToClose's AppleScript solution and comment, you do not need to extract the time. – Mego Nov 28 '15 at 3:36 • Another 24-byte solution: {sleep say~~gmtime;redo}. – Denis Ibaev May 17 '16 at 20:14 • sleep 1 based answer break rule 5: you must guarantee one, and only one, output of time per second. – F. Hauri May 17 '16 at 23:05 • @F.Hauri the rule was added after this post was made. – primo May 18 '16 at 0:29 # Javascript ES6, 43 39 bytes setInterval(_=>console.log(Date()),1e3) Works with my current time settings (which have not been changed for some time, thank you), at least. 4 bytes saved by Conor O'Brien. • alert is shorter? – Maltysen Nov 27 '15 at 23:09 • @Maltysen I think in many browsers you have to close one alert window in order to see the next one. – flawr Nov 27 '15 at 23:10 • @Maltysen I tried it, messes up the interval somehow – SuperJedi224 Nov 27 '15 at 23:11 • You don't need .toTimeString() in Chrome and FF. – Bob Nov 30 '15 at 6:45 • I think you can replace new Date() with Date() – Conor O'Brien Dec 13 '15 at 22:39 # Arcyóu, 27 bytes (@ t(pn(zz 1)(p(st %H:%M:%S I had to kludge together two new functions for this challenge, zz and st. pn: Exactly like Lisp's progn. zz: Direct link to Python's time.sleep. st: Direct link to Python's time.strftime. Normally, quotes would be necessary around the format string, but since there are no spaces, it's parsed as a symbol. The interpreter evaluates undefined symbols as themselves, so we get a string. • I would up vote, but I don't have any votes left. +1 ;c And nice updates. :D – Addison Crump Nov 28 '15 at 20:54 # Bash, 51312421 20 bytes Thanks to @quartata for some very helpful comments. Thank you @Dennis for clarifications and for chopping off even more bytes. Thank you @VoteToClose for clarifying the rules (which apparently I am bad at reading) further reducing the bytes. date displays the the full date with a 24 hour clock. sleep 1 sleeps for a second. exec$0 loops the script infinitely.

date;sleep 1;exec $0 • You don't need the shebang. – a spaghetto Nov 28 '15 at 2:52 • Also, I think you can replace the true with the sleep 1 since sleep returns a 1. – a spaghetto Nov 28 '15 at 2:52 • date +%T;sleep 1;exec$0 is a bit shorter. @quartata Nitpicking: sleep has exit code zero, which is why while continues. – Dennis Nov 28 '15 at 3:47
• Oh I'm an idiot – a spaghetto Nov 28 '15 at 3:50
• You don't need the space after date, so this is only 20 bytes. – ThisSuitIsBlackNot Nov 30 '15 at 1:46

# Befunge 98, 53 bytes

v
v>"EMIT"4(>H.8,':,M.8,':,S:.8,d,
>:S-    !!k^

Notes:

1. This program does not zero-pad the numbers it prints.
2. This program prints a space and then a backspace character after every number, as the . command prints an implicit space at the end.
3. The size of the stack in this program grows every second, and thus it will eventually run out of memory.
4. This program will overwrite the previous time when it prints a new one. To make it print each time on a new line, change the d on the first line to an a
• Why is the "TIME" string necessary? Is there some way it's grabbing it? (I didn't know about this) – Addison Crump Nov 27 '15 at 23:38
• The "EMIT"4( at the beginning of the program is telling the interpreter to load the TIME fingerprint, which enables the H,M, and S instructions. (No, it doesn't emit the number 4). – pppery Nov 27 '15 at 23:39
• That is awesome. I never even thought that many esolangs would do this, +1. – Addison Crump Nov 27 '15 at 23:41
• @VoteToClose Befunge 98 even has an instruction to execute an arbritrary program popped from the stack. – pppery Nov 27 '15 at 23:42
• runs off to learn this language Excuse me... – Addison Crump Nov 27 '15 at 23:42

/timer 0 1 $time • Where can we test this? – Addison Crump May 31 '16 at 12:56 • You have to download mIRC it's a shareware IRC client. You can download it from: mirc.com also since the answer above makes use of say you will need to connect to a server and then join a channel. other wise you would use echo instead of say. mIRC has it's own scripting language mSL(mIRC scripting language) – Do0msDay May 31 '16 at 14:01 ## AutoHotkey, 50 bytes x::Send,% a!=A_Sec? A_Hour ":" A_Min ":" a:=A_Sec: Notes: 1. Requires you to hold x for continuous output. 2. Remove your finger from x to interrupt and end the output. 3. Output is in 24-hour format. • You could, for a few extra bytes, put that in a tooltip so it doesn't require the user to hold x. – Michelfrancis Bustillos May 18 '16 at 11:58 # C (on Linux x64), 179177175168 159 bytes #include<time.h> #include<sys/time.h> main(){struct timeval a;char b[9];for(;;){gettimeofday(&a,0);strftime(b,9,"%T",localtime(&a.tv_sec));puts(b);sleep(1);}} Ungolfed: #include <time.h> #include <sys/time.h> main(){ struct timeval a; char b[9]; for(;;){ gettimeofday(&a, 0); strftime(b, 9, "%T",localtime(&a.tv_sec)); puts(b); sleep(1); } } Only tested on, and likely only functions on, linux x64 (x32 might work, but other platforms probably won't). The main difference between this program and the other posted C program is the use of linux-exclusive function calls, which, while terrible practice for real software, saves quite a few bytes...if you ignore all the compiler warnings. • Welcome to PPCG! Unless I'm mistaken, I believe you can remove the space between #include and <...>. Also, can you use 1e6 instead of 1000000? – Addison Crump Nov 28 '15 at 14:33 • @VoteToClose You were right about the spaces in the #includes. It doesn't look like usleep() accepts 1e6, though - based on how fast it starts spitting out timestamps it just interprets it as 1. – Gamerdog Nov 28 '15 at 14:37 • ¯\_(ツ)_/¯ I don't really know C, either. I'll let the professionals at that. Welcome again, have an up vote. :D – Addison Crump Nov 28 '15 at 14:39 • Ah, another thing - you don't have to cut the string for just the time, so you can just output the entire date time, provided it has the time string required in it. – Addison Crump Nov 28 '15 at 14:42 • You can use %T as the format spec in strftime. – Mego Nov 29 '15 at 2:41 # Jolf, 148 7 bytes Crossed out 14 is a striked 1? Naw, it will never catch on ;) Try it here! Click run, do not click on anything else ^_^ the page is highly... explosive. Yes. Fixed output system with update. TaD#~2 (I added some constants, and ~1 to ~4 are powers of 10.) ## Explanation setInterval("alert(Date())",1000); T a D#  ~2 • Someone should create YAJSGV (Yet Another JavaScript Golfing Variant). – intrepidcoder Nov 28 '15 at 3:43 • This seems to print a lot more than just the time. – Dennis Nov 28 '15 at 3:45 • @Dennis I assumed that was fine as per other solutions – Conor O'Brien Nov 28 '15 at 3:48 • My bad, I had only read yours and the Bash answer. – Dennis Nov 28 '15 at 3:48 • @Dennis Not a problem ^_^ – Conor O'Brien Nov 28 '15 at 3:48 # Dyalog APL, 27 18 16 bytes ':',¨⎕TS⋄→≢⎕DL 1 Try it online! ⎕TS Y M D h m s t ':',¨ prepend : to each new statement ⎕DL 1 wait a second and return actual waited time; 1.0something seconds tally the actual waited time, giving 1 go to line (1 = this line) ## Perl 6, 29 bytes The right way to do this: Supply.interval(1).tap: ->$ {
say join ':',.hour,.minute,.whole-second given DateTime.now
}
await Promise.new; # halt this thread indefinitely
22:21:58
22:21:59
22:22:0
22:22:1
22:22:2
…

The golfed version

loop {sleep say join ':',now.polymod(1,60,60,24)[3…1]} # 56 bytes
3:59:26
3:59:27
3:59:28
3:59:29
…

Since the output doesn't have to be restricted to just the time, I can make it quite a bit shorter.

loop {sleep say DateTime.now} # 29 bytes
2015-11-27T22:18:10-06:00
2015-11-27T22:18:11-06:00
2015-11-27T22:18:12-06:00
2015-11-27T22:18:13-06:00
…

## R, 38 bytes

repeat{Sys.sleep(1);print(Sys.time())}

This outputs the current time in the following format:

[1] "2015-11-28 07:34:01 CET"

## Powershell, 19 bytes

for(){date;sleep 1}
• As it's since been pointed out that output merely needs to include the hh:mm:ss you can reduce to for(){date;sleep 1} – steve Nov 28 '15 at 23:25

# PHP, 37 bytes

Outputs the formatted server time and sets the page to refresh every second.

Of course, it depends on your internet connection and how fast-repsonding your server is :)

Demo

• Nope, no refreshing : Warning: Cannot modify header information - headers already sent – Martijn Nov 30 '15 at 14:20
• @Martijn I have no idea what you can mess with, because it works for me :) – nicael Nov 30 '15 at 14:40
• I'll remove the downvote as benefit of the doubt, but this works exactly once for me. Tried on two different regular servers. – Martijn Nov 30 '15 at 14:42
• Depends on whether you have output buffering turned on. – Andrea Jul 11 '16 at 0:10
• <?=header('refresh:1').date('G:i:s'); should work with either output bffering setting. – Jasen Jan 7 '17 at 11:17

# VBA, 69 Bytes

Getting the Time is easy, now() Only outputting every 1 second.... MUCH more verbose.

This is the "Right" way of waiting 1 second in VBA. 78 Bytes

Sub a():Debug.Print Now():Application.Wait Now()+TimeValue("0:0:1"):a:End Sub

Or if you want to Cut some Corners and only being right 86% of the time is good enough 63 Bytes
adding one SigFig take you to 95% accurate and a third will get you to 99.36%

Sub a():Debug.Print Now():Application.Wait Now()+1e-5:a:End Sub

If you want to get the above method to 100% then you need 69 Bytes (1/86400)

Sub a():Debug.Print Now():Application.Wait Now()+(1/86400):a:End Sub

All of these methods would stumble on a leap second Beacuse they do not wait for 1 second, But wait untill 1 second. At midnight when the clocks fall back an hour this clock will stop for 1 hour and then pick up where it left off.

VBA does allow for the Sleep Method but your byte couter is Ruined. 97 Bytes

Declare Sub Sleep Lib "kernel32" (ByVal k as Long)
Sub a():Debug.Print Now():Sleep(1e3):a:End Sub

# JavaScript, 4738 35 bytes

## Explanation

Continuously checks if the time has changed then alerts if it has.

for(
p=1;
t=Date();
p=t
)
t!=p
• You don't have to just get the time string. ;D As long as it's in there somewhere. – Addison Crump Nov 28 '15 at 0:49
• @VoteToClose Oh true! – user81655 Nov 28 '15 at 0:54
• Don't think you need the +"", as without new, Date() returns a string. – ETHproductions Nov 28 '15 at 1:25
• @ETHproductions Ah, yes that was left there from when it used new. Thanks for catching that! – user81655 Nov 28 '15 at 1:29

# AppleScript, 51 35 bytes

repeat
log current date
delay 1
end

Pretty dang obvious. Prints the current date, which contains the time, delays a second, then continues.

• So wait, is it allowed to print out the current date as well as the time? – a spaghetto Nov 28 '15 at 3:31
• @quartata Yes, any concatenation with the time, as long as the time is continuously output and guaranteed to be output, is fine. – Addison Crump Nov 28 '15 at 10:59
• delay 1 does what? pause for 1000000000 ns? – Jasen Jan 7 '17 at 11:19
• @Jasen That's correct. – Addison Crump Jan 7 '17 at 12:22

# 𝔼𝕊𝕄𝕚𝕟, 13 chars / 25 bytes

Ĥ⇀ôᶁ⬮+⬬),1𝕜)

Try it here(Firefox only).

• When you say "surprisingly readable", you know you're dealing with an amusing language. +1 – Addison Crump Nov 29 '15 at 0:47

# Dyalog APL, 36 bytes

Not very short this time.

{⎕←1↓∊'⊂:⊃,ZI2'⎕FMT 3↑3↓⎕TS⋄∇⎕DL 1}1

This outputs 24-hour time, i.e.:

14:37:44
14:37:45
14:37:46
...

Explanation:

• {...}1: define a function and call it (the argument is ignored, but we need the function in order to call it recursively)
• ⎕TS: a system function that returns the current date and time, in the format year - month - day - hour - minute - second - millisecond. (⎕TS = timestamp)
• 3↑3↓: drop the first 3 items (i.e. year - month - day) and then take the first 3 items that are left (hour - minute - second).
• '⊂:⊃,ZI2'⎕FMT: format each number as a two-digit integer (I2) with leading zeroes (Z), prefixed by a colon (⊂:⊃). (This results in a matrix.)
• : Get all the elements in the matrix, in row order. (This gives a vector, in this case a string.)
• 1↓: drop the first character (which is an extra :)
• ⎕←: output it
• ⎕DL 1: then wait one second (⎕DL = delay)
• : call the function recursively
• {⎕←1↓∊':',¨⍕¨3↑3↓⎕TS⋄∇⎕DL 1}1 for 28 bytes, is enough as per OP. – Adám Dec 10 '15 at 1:25
• The new rules allow garbage output and random spaces, so you can get rid of a lot. – Adám Jan 5 '16 at 22:51