28 Sep 2020

Date Widget : Show Today’s Nepali Date in your website

Notice: This widget has been deprecated. This post is only kept for historical purpose. You can checkout code in Github if your want to implement it yourself.

Overview

DateJS (Date Widget) is a simple javascript widget to display today’s Nepali date in your site. If you want to display date in Bikram Sambat (BS) dynamically, then its easy now. This widget will do that job. You can either show date in English language or in Nepali unicode. It can be configuration easily. Different date formats are available. See Settings section for available date formats. It is not necessary to include any javascript library for using this widget.

Features

  • Simple and easy to install
  • Customizable
  • Supports display language; English or Nepali
  • Various date formats
  • Supports time also
  • Time may be in 24hr or 12hr format
  • Supports multiple instance in single page

How To

Intalling this widget is very easy. You just need to copy given code and after customizing it, paste it to your web page. If you are using any CMS or blogging service then paste it in Text/Html widget.
Basic Installation

<script src="http://nilambar.com.np/dateapi/widget.js"></script> 
<script id="mywidget">
DateJS.Widget();
</script>

Advanced Installation

<script src="http://nilambar.com.np/dateapi/widget.js"></script> 
<script id="mydatewidget">
DateJS.Widget({  
  dateLanguage : 'np',
  dateFormat : 6,
  showPoweredBy : true,
  widgetId : 'mydatewidget'
});
</script>

Example

To see demo, check sidebar of this blog. 🙂

Settings

Property Default Description
dateLanguage ‘np’ Language to display date. Either ‘en’ or ‘np’.
Example :
np : १९ साउन २०६९, शुक्रबार
en : 19 Shrawan 2069, Friday
dateFormat 6 Integer value assigned for various date formats.
Example:
1 : १९ ०४ २०६९
2 : २०६९ १९ ०४
3 : २०६९ ०४ १९
4 : १९ साउन २०६९
5 : २०६९ साउन १९
6 : १९ साउन २०६९, शुक्रबार
7 : शुक्रबार, १९ साउन २०६९
8 : २०६९ साउन १९, शुक्रबार
9 : शुक्रबार, २०६९ साउन १९
widgetId ‘mywidget’ ID of the widget. If you are using single widget in a page then no need to set this option.
For multiple widgets, assign different name to each script’s ID and pass that in this parameter.
dateSeparator ‘ ‘ (space) Date separator. Default is space. You may use ‘-‘, ”, ‘/’.
showTime true Option to whether display time or not. Enter false to disable
militaryTime false true will show time in 24 HOUR format. false for 12 HOUR format
showTimeBeforeDate false Show time after date if false. Use true if you want to display time before date.
multiLine false Set to true if you want to display date and time in separate line.
showPoweredBy true Enable of disable the banner display below the date. Setting false will disable it. [ I would appreciate if you enable banner 😛 ]

Thanks to Jonathan Julian for his example_javascript_widget using which I was able to make this widget. And also kudos to codeartsnepal for Nepali-English Date conversion PHP class.

Nilambar

PHP Programmer, WordPress and Laravel Developer, Freelancer and a Blogger.

View all posts by Nilambar →

5 thoughts on “Date Widget : Show Today’s Nepali Date in your website

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.