param timestamp export const timestampToTimeAgoStr = ( timestamp ) => { const secsDiff = window . StackExchange . options . serverTimeOffsetSec + ( ( Date . now ( ) - timestamp ) / 1000 ) ; const dayDiff = Math . floor ( secsDiff / 86400 ) ; if ( secsDiff < 2 ) { return 'now' ; } if ( secsDiff < 60 ) { return `${ Math . floor ( secsDiff ) }s` ; } if ( secsDiff < 3600 ) { return `${ Math . floor ( secsDiff / 60 ) }m` ; } if ( dayDiff === 0 ) { return `${ Math . floor ( secsDiff / 3600 ) }h` ; } if ( dayDiff <= 2 ) { return `${ dayDiff }d` ; } const date = new Date ( timestamp ) ; return `${ date . toLocaleString ( undefined , { month : 'short' } ) } ${ date . getUTCDate ( ) }` ; } ;