This BJS code gets the current date and time in the 🕒 "Asia/Kolkata" timezone. It extracts:
• 📅 Day
• 📆 Month
• 📅 Year
• 📅 Weekday
• ⏰ Hours
• 🕒 Minutes
• ⏱️ Seconds
• 🕰️ Milliseconds
It formats the info and sends a message in HTML format with details like the full date, time, and timezone! 🌍✨
🔍 BJS:
let free = new Date().toLocaleString("en-US", {
timeZone: "Asia/Kolkata"
});
let dateObj = new Date(free); // Create a new Date object for the current time
// Extracting details using JavaScript Date methods
var day = dateObj.getDate(); // Day of the month (1-31)
var monthNumber = dateObj.getMonth() + 1; // Month number (1-12)
var year = dateObj.getFullYear(); // Full year (e.g., 2024)
var weekdayNumber = dateObj.getDay(); // Day of the week (0-6, where 0 is Sunday)
var hours = dateObj.getHours(); // Hours (0-23)
var minutes = dateObj.getMinutes(); // Minutes (0-59)
var seconds = dateObj.getSeconds(); // Seconds (0-59)
var milliseconds = dateObj.getMilliseconds(); // Milliseconds (0-999)
// Weekday names array
var weekdayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var weekdayName = weekdayNames[weekdayNumber];
// Month names array
var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var monthName = monthNames[monthNumber - 1];
// Extracting details using Libs.DateTimeFormat
var formattedDate = Libs.DateTimeFormat.format(free, "dd/mm/yyyy");
var formattedTime = Libs.DateTimeFormat.format(free, "h:MM:ss");
// Extract ISO week number
var weekNumber = Libs.DateTimeFormat.format(free, "W"); // Week number (ISO standard)
// Edit the existing message with the full date and time information
Api.sendMessage({
text: "📅 Full Date and Time Information:\n" +
"------------------------------------------\n" +
"🗓 Day: " + day + "\n" +
"📆 Month (Number): " + monthNumber + "\n" +
"📅 Month (Name): " + monthName + "\n" +
"📅 Year: " + year + "\n" +
"🗓 Day of the Week: " + weekdayName + "\n" +
"📆 Week Number: " + weekNumber + "\n\n" +
"⏰ Time Information:\n" +
"------------------------------------------\n" +
"⏲ Hours: " + hours + "\n" +
"🕐 Minutes: " + minutes + "\n" +
"⏱ Seconds: " + seconds + "\n" +
"⏲ Milliseconds: " + milliseconds + "\n\n" +
"📊 Formatted Date and Time:\n" +
"------------------------------------------\n" +
"🗓 Formatted Date (dd/mm/yyyy): " + formattedDate + "\n" +
"⏲ Formatted Time (hh:mm:ss): " + formattedTime + "\n\n" +
"🌍 Timezone: Asia/Kolkata",
parse_mode: "html"
});
🎖 Must Install “DateTimeFormat” Lib.
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
😎
Demo Of Code :-
Click Here
❤️ OWNED BY THIS MESSAGE SENDER ✅