Last active
January 20, 2021 11:14
-
-
Save hallojoe/a00b40af4980231533e6446d3f96ac30 to your computer and use it in GitHub Desktop.
Inherit time from source date time
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
function inheritTimeFrom(source, target) { | |
var sourceDateTime = new Date(source) | |
var targetDateTime = new Date(target) | |
targetDateTime.setHours(sourceDateTime.getHours()) | |
targetDateTime.setMinutes(sourceDateTime.getMinutes()) | |
targetDateTime.setSeconds(sourceDateTime.getSeconds()) | |
targetDateTime.setSeconds(sourceDateTime.getMilliseconds()) | |
return targetDateTime | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment