Created
July 30, 2021 02:41
-
-
Save GuilhermeRossato/2d54f5000faf3b7f81b55c500b5a8a4c to your computer and use it in GitHub Desktop.
Get Brazilian Date Time String (UTC-3) - A javascript function to return a datetime string in UTC-3 in the format "yyyy/mm/dd hh:mm:ss" from a Date object
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
| /** | |
| * Returns a UTC-3 datetime string from a given date object | |
| * @param {Date} date The date to retrieve the string from (default current date) | |
| * @returns {'2021-07-29 23:37:25' | string} A string in the format "yyyy/mm/dd hh:mm:ss" | |
| */ | |
| function getBrazilianDateTimeString(date = new Date()) { | |
| date.setTime(date.getTime() - 3 * 60 * 60 * 1000); | |
| return date.toISOString().replace("T", " ").split(".")[0]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment