Here is an example in Javascript which works well on Android but does not work for iOS. I don’t know why?
showTime = function(timeId, time_incoming) {
var curTime = new Date();
var time_in = new Date(time_incoming);
var curTimeStr = curTime.format('yy/mm/dd');
var inTimeStr = time_in.format('yy/mm/dd');
if (curTimeStr === inTimeStr)
{
$("#" + timeId).text(curTimeStr);
}
else
{
$("#" + timeId).text(inTimeStr);
}
}
The
Dateobject in JavaScript has noformatfunction.Separately, re this line:
You haven’t said what
time_incomingis, but if it’s a string, you need to be sure it’s a string in a format that is actually supported. A lot of browsers add to the formats that are supported, but you can’t rely on it. The only string format that’s officially supported is a simplified form of ISO 8601, but that’s relatively new (only specified a couple of years ago) and not present in older browsers. All desktop browsers also supportyyyy/mm/dd(with slashes, not dashes), even though that’s not specified. So iftime_incomingis a string, you may need to parse it yourself.