DEV Community

Risyandi
Risyandi

Posted on • Originally published at Medium on

Membuat Timestamp Footer Dinamis Dengan Javascript

images

Source by : pexels.com

Kali ini saya akan membahas tentang bagaimana cara membuat sebuah timestamp di footer dinamis, dimana biasanya timestamp di footer itu statik dan tidak otomatis update ketika atau saat perpindahan tahun.

Berikut adalah kode yang bisa teman-teman coba, saya menggunakan Javascript murni untuk membuatnya berikut adalah kodenya :

<footer>
  <script>  
    **document.write(new date().getFullYear());** </script>
</footer>
Enter fullscreen mode Exit fullscreen mode

dan hasilnya akan jadi seperti ini,

**2019**
Enter fullscreen mode Exit fullscreen mode

dan contoh yang lainnya bisa teman-teman seperti berikut ini :

<footer>&copy; name company, since 1994
 <script>
**document.write("- " + new Date().getFullYear());**
 </script>
</footer>
Enter fullscreen mode Exit fullscreen mode

dan hasilnya akan jadi seperti ini,

**© name company, since 1994 – 2019**
Enter fullscreen mode Exit fullscreen mode

itulah yang bisa saya bahas, semoga bermanfaat, dan untuk detail penggunaan metode date() ini bisa cek disini , selamat mencoba! 😃

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay