Advertisement
Guest User

Untitled

a guest
May 21st, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. const formatDateToUTC = date => {
  2. const month = `${date.getUTCMonth() + 1}`;
  3. const day = `${date.getUTCDate()}`;
  4. const hour = `${date.getUTCHours()}`;
  5. const min = `${date.getUTCMinutes()}`;
  6. const year = `${date.getFullYear()}`;
  7.  
  8. const list = [year, month, day, hour, min];
  9. return list
  10. .map(v => {
  11. if (v.length === 1) {
  12. return `0${v}`;
  13. }
  14. return v;
  15. })
  16. .join('');
  17. };
  18.  
  19. module.exports = formatDateToUTC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement