Created
June 7, 2019 03:24
-
-
Save srph/a223c774990a02eca5025ca81b27dd2e to your computer and use it in GitHub Desktop.
JS: mysql-formatted string with date-fns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { format } from 'date-fns' | |
/** | |
* Gives you a mysql standard formatted datetime | |
* e.g., 2018-08-08 23:00:00 | |
*/ | |
function getStandardFormattedDateTime(date: Date = new Date()) { | |
return format(date, 'YYYY-MM-DD HH-mm-ss') | |
} | |
export default getStandardFormattedDateTime |
// v2.16.1
format(new Date(), 'yyyy-MM-dd HH-mm-ss')
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks