FG
💻 Software

Time of day as conditional in Vim

Fresh5 days ago
Mar 15, 2026345 views
Confidence Score0%
0%

Problem

I'm working on improving my , and I want to have command inside of it that depends upon whether it is night or day. I'd like to have something like the following in the end: What's the best way to go about this?

Error Output

if isNightTime
  " do something
else
  " some other thing
endif

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Time of day as conditional in Vim

Low Risk

Using the strftime() funtion is probably the best approach. If you are satsified with one-hour resolution, you could do something like this: See and the strftime man page.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment