
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
datetime-str
Advanced tools
Open your project's directory and execute next command:
npm install --save datetime-str
In order to use package in your project it should be assigned to the variable
const datetime_str = require('datetime-str');
Next command will create variable datetime_str that will hold module
monthNames - Names of months starting from JanuarymonthNamesPart - Contains first 3 symbols of each month namedayNames - Names of days of week starting from SundaydayNamesPart - Contains first 3 symbols of each day nameformats - Contains list of standart patternsformat(pattern, date) - Creates string by pattern using given datemonthNames - names of months from JanuaryType: array
Length: 12
Values:
[
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
]
monthNamesPart - first 3 symbols of months namesType: array
Length: 12
Values:
[
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec'
]
dayNames - Names of days of week starting from SundayType: array
Length: 7
Values:
[
'Sunday',
'Monday',
'Tuesday',
'Wednessday',
'Thursday',
'Friday',
'Saturday'
]
dayNamesPart - first 3 symbols of day namesType: array
Length: 7
Values:
[
'Sun',
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat'
]
formats - Contains list of standart patternsType: object
Keys: default, en, ru
{
'full' : '{yyyy mmmm d HH:MM:SS} UTC {UTC}',
'datetime' : '{yyyy-mm-dd HH:MM:SS}',
'datetime12' : '{yyyy-mm-dd HH12:MM:SS AMPM}',
'date' : '{yyyy-mm-dd}',
'time' : '{HH:MM:SS}',
'time12' : '{HH12:MM:SS AMPM',
'precise' : 'SS.LL'
}
{
'full' : '{mmmm d yyyy HH:MM:SS} UTC {UTC}',
'datetime' : '{mm/dd/yyyy HH:MM:SS}',
'datetime12' : '{mm/dd/yyyy HH12:MM:SS ampm}',
'date' : '{mm/dd/yyyy}'
}
{
'full' : '{yyyy mmmm d HH:MM:SS} UTC {UTC}',
'datetime' : '{dd.mm.yyyy HH:MM:SS}',
'datetime12' : '{dd.mm.yyyy HH12:MM:SS ampm}',
'date' : '{dd.mm.yyyy}'
}
format(pattern, date) - Formats date using patternpattern - string
date - standart Date object
Pattern is a simple string that can contains any symbols
To designate where formated date should be placed {}(curly braces) are used
Simple pattern that shows current time will be:
'Current time is {HH} hours {MM} minutes {SS} seconds'
It is possible to use multiple keys within {}(curly braces)
'Current time: {HH:MM:SS}`
They can be splited by any not alpha-numeric symbols
yyyy - full year. Example: 2002
yy - two-digit year with leading zero. Example: 02
y - two-digit year without leading zero. Example: 2
mm - month with leading zero
m - month without leading zero
dd - day with leading zero
d - day without leading zero
mmmm - Month name. Full form
mmm - Month name. Only first 3 symbols
dddd - Day of week. Full form
ddd - Day of week. Only first 3 symbols
HH24 - 24 hours time with leading zero
HH - 24 hours time with leading zero. Shortcut
HH12 - 12 hours time with leading zero. Should be used together with ampm
H24 - 24 hours time without leading zero
H - 24 hours time without leading zero. Shortcut
H12 - 12 hours time without leading zero. Should be used together with ampm
MM - Minutes with leading zero
M - Minutes without leading zero
SS - Seconds with leading zero
S - Seconds without leading zero
LL - Milliseconds with leading zero
L - Milliseconds without leading zero
ampm - Current half of the day as am or pm
AMPM - Current half of the day as AM or PM
UTC - Time zone offset. Example +1 or -2:30
FAQs
Converts Date object to string with some format
We found that datetime-str 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.