How to add current date/time to clink/cmder prompt

The answer provided by Maximus is no longer valid for cmder 1.3+

You have to create a .lua file (for ex. my_prompt.lua) inside your cmder config folder with your customized definition (source).

Below my customization:

function custom_prompt()
  cwd = clink.get_cwd()
  prompt = "\x1b[1;32;40m{cwd} {git}{hg} \n\x1b[1;30;40m{time}\n{lamb} \x1b[0m"
  new_value = string.gsub(prompt, "{cwd}", cwd)
  add_time = string.gsub(new_value, "{time}", os.date("%x - %X"))
  clink.prompt.value = string.gsub(add_time, "{lamb}", "λ")
end

clink.prompt.register_filter(custom_prompt, 1)

And this is the resulting prompt

C:\
03/25/17 - 20:56:14
λ

You can find more customization options for the time output in the Lua manual


update for comment reported error

function time_prompt()
    os.setlocale ("", "time")
    local cwd = clink.get_cwd()
    local prompt = "\x1b[1;32m{cwd} {git}{hg} \n\x1b[30m{time}\n{lamb} \x1b[0m"
    local new_value = string.gsub(prompt, "{cwd}", cwd)
    local add_time = string.gsub(new_value, "{time}", os.date("%x - %X"))
    clink.prompt.value = string.gsub(add_time, "{lamb}", "λ")
end

Try this prompt settings (example only, it's show how you can call any console application inside "prompt printing"). Note! It works in ConEmu only.

prompt $p$s$e]9;7;"cmd /c echo (%DATE% %TIME%)"$e\$g

But, as Bob said, there is an easier way:

prompt $p$s$d$s$t$s$g

And for cmder you should edit the supplied init.bat as that defines the prompt settings.