Advertisement
shapoval

dateTimeHelper.ts

Sep 21st, 2022
1,451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export function timestampToFormattedDate(timestamp: number): string {
  2.     const date = new Date(timestamp * 1000);
  3.  
  4.     return `${ date.getDate() }.${ date.getMonth()+1 }.${ date.getFullYear() }`;
  5. }
  6.  
  7. export function timeLabelFromSeconds(seconds: number): string {
  8.     if (seconds >= 3600) {
  9.         // hh:mm:ss
  10.         return new Date(seconds * 1000).toISOString().slice(11, 19);
  11.     } else {
  12.         // mm:ss
  13.         return new Date(seconds * 1000).toISOString().slice(14, 19);
  14.     }
  15. }
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement