Apoya a Time.now: Únete a nuestro Plan Premium ¡para una experiencia sin anuncios! Apóyanos: ¡Hazte Premium sin anuncios!
Frontend Guía

JavaScript Fetch API Example

You don't always need a massive framework like React or Angular. Modern browsers support the `fetch()` API natively, allowing you to get atomic time data with just a few lines of plain JavaScript.

JAVASCRIPT
// 1. Select the DOM element
        const display = document.getElementById('time-display');

        // 2. Fetch data
        fetch('https://time.now/developer/api/timezone/Europe/London')
          .then(response => {
            if (!response.ok) throw new Error('Network response was not ok');
            return response.json();
          })
          .then(data => {
            // 3. Update the UI
            console.log(data);
            display.innerText = `London Time: ${data.datetime}`;
          })
          .catch(error => console.error('Error:', error));

¿Por qué usar Time.Now para Frontend?

  • Zero dependencies
  • Works in all modern browsers
  • Copy-paste ready
Referencia de la API Ver todas las guías