How do get different form of date datetime and full date depending upon the scenarios.
- 1 In case date is newest less than 24 Hr oldthen I have to show like22:31
- In case date is of same month for e.g februarybut older than24 hrthen I have to show like15 Feb.
- In case date is older than a month then I have to show like 15 Feb 17.
Till now I have made two javascript function for the purpose .
function getLocalizeDateTime(dateString,format) {
if(dateString==null || dateString==undefined || dateString==""){
    return "";
}
var dateTime = dateString.trim().split(" ");
var dateOnly = dateTime[0];
var timeOnly = dateTime[1];
timeOnlyOfDate = timeOnly;
var temp = dateOnly + "T" + timeOnly+"Z";
var utc_date =new Date(temp);
currentDateStr = dateString;
//var offset = new Date().getTimezoneOffset();
//utc_date.setMinutes(utc_date.getMinutes() - offset);
  if(format!=undefined && format!=null)
  return date2str(utc_date,format);
  return date.toString();
 }
function date2str(x, y) {
var z = {
    YR: x.getFullYear(),
    M: x.getMonth() + 1,
    d: x.getDate(),
    h: x.getHours(),
    m: x.getMinutes(),
    s: x.getSeconds()
};
// Here return 22:32 if date is less than 24 hr old.
// return 24 feb as currentmonth is feb.
// return 24 feb 17 in case current date is march or greater.
y = y.replace(/(M+|d+|h+|m+|s+)/g, function(v) {
    return ((v.length > 1 ? "0" : "") + eval('z.' + v.slice(-1))).slice(-2)
});
return y.replace(/(y+)/g, function(v) {
    return x.getFullYear().toString().slice(-v.length)
 });
}
But these functions return whole date in format for e.g for date "2017-02-24 07:46:38"  and format MM-dd-yyyy hh:mm" it is returning 02-24-2017 13:16. How do acheve above mentioned 3 business check.
 
     
     
    