Custom Components
Current Date and Time
Current Date and Time
Instructions
Overview
Easily add a live date and time display to your website with customizable formatting and timezone adjustments.
Getting Started
Quick Start
- Click the Copy Component button on the top of the page.
- Paste the component into your Webstudio site.
Manual Start
- Add the Script: Copy and paste this code into your website's after the component:
[code-block]<script type="module" src="https://drevo.b-cdn.net/Library/Custom%20Components/Current%20Date%20Time/current-date-time-v1.0.js"></script>[/code-block]
- Add the Display Element: Place a Box element or a
<div>
where you want the date and time to appear, and add these custom attributes:<div dv-datetime-format="Y-M-D h:m:s" dv-datetime-timezone="0"></div>
Customization Options
Date & Time Format
- Use these placeholders in the
dv-datetime-format
attribute:Y
= Year (e.g., 2023)M
= Month (e.g., 10)D
= Day (e.g., 05)h
= Hour (e.g., 14)m
= Minute (e.g., 30)s
= Second (e.g., 00)
- Example:
dv-datetime-format="D/M/Y h:m"
→ "05/10/2023 14:30"
Timezone Adjustment
- Use the
dv-datetime-timezone
attribute to set the timezone offset from UTC. - Example:
dv-datetime-timezone="2"
→ UTC+2 - Valid range: -12 to 12
Notes
- The time updates automatically every second.
- If the timezone is invalid, it will show "Invalid timezone".
- Only use the specified placeholders in the format string; other characters will appear as-is.