Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
I absolutely love the moment.js library, but at times it runs a bit heavier than I really need. I like the simplicity of PHP's built-in date()
function and wrote this to be sort of similar.
<script src="daylight.js"></script>
<script>
var today = daylight('l, F jS', Date.now());
var p = document.createElement('p');
p.innerText = today;
document.body.appendChild(p);
//=> <p>Wednesday, May 28th</p>
</script>
install with npm install daylight
, run tests with npm test
, etc.
var daylight = require('daylight');
console.log(daylight('l, F jS', Date.now()));
//=> Wednesday, May 28th
these are copied from php's date()
function
characters not on this list are passed normally; to escape characters you'll have to use double backslashes:
var today = daylight('\\d\\a\\y: l', Date.now());
console.log(today);
//=> day: Wednesday
string | format | example |
---|---|---|
d | day of month, with leading zero | 01 to 31 |
D | day of week, three letter abbreviation | Sun to Sat |
j | day of month, without leading zero | 1 to 31 |
l (lower-case L) | day of week, full word | Sunday to Saturday |
N | numeric day of the week | 1 to 7 |
S | English suffix | st, nd, rd, th |
w | zero-based day of the week | 0 (Sunday) to 6 |
z | numeric day of the year | 1-366 |
F | month, full word | January to December |
m | month with leading zero | 1 to 12 |
M | month, three letter abbreviation | Jan to Dec |
n | month without leading zero | 1 to 12 |
Y | four-digit year | 1989 or 2014 |
y | two-digit year | 89 or 14 |
a | lowercase ante or post meridiem | am or pm |
A | uppercase ante or post meridiem | AM or PM |
g | 12-hour format, no leading zero | 1 to 12 |
G | 24-hour format, no leading zero | 0 to 23 |
h | 12-hour format, leading zero | 01 to 12 |
H | 24-hour format, leading zero | 00 to 23 |
i | minutes, with leading zero | 00 to 59 |
s | seconds, with leading zero | 00 to 59 |
FAQs
lightweight javascript date formatting
The npm package daylight receives a total of 17 weekly downloads. As such, daylight popularity was classified as not popular.
We found that daylight demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.