Skip to content

Instantly share code, notes, and snippets.

@Remonhasan
Last active December 5, 2022 18:55
Show Gist options
  • Save Remonhasan/7c972131d24be5052027c2afe532d61d to your computer and use it in GitHub Desktop.
Save Remonhasan/7c972131d24be5052027c2afe532d61d to your computer and use it in GitHub Desktop.
JavaScript Functions Handbook
// Get Current Date and Time
const current = new Date();
const year = current.getFullYear();
const day = String(current.getDate()).padStart(2, '0');
const month = String(current.getMonth() + 1).padStart(2, '0');
const time = + current.getHours() + ":" + current.getMinutes() + ":" + current.getSeconds();
const currentDateTime = `${year}-${month}-${day} ${time}`;
const covertCurrentDateTime = DateTimeUtils.formatTimestamp(currentDateTime);
// Convert Time for Zoom Meeting
function timeConvert(n) {
var num = n;
var hours = (num / 60);
var rhours = Math.floor(hours);
var minutes = (hours - rhours) * 60;
var rminutes = Math.round(minutes);
return rhours + "." + rminutes;
}
timeConvert(120);
// Seperate Only Time
function separateTime(n) {
var now = new Date(n)
var time = now.toLocaleTimeString();
return time;
}
// Translate English Number to Bangla
const toBn = n => n.toString().replace(/\d/g, d => "০১২৩৪৫৬৭৮৯"[d])
// Date time Ul
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment