refactored date in jquery view function