Im making an app that users can post stuff and i need to display a date on the post.
When a user makes a post, the database creates a value for createdAt like this: “2015-06-11T17:53:54.781Z”
I managed to get each part of the date, but now, with the new Uno.Time, i cant create a new date with those values.
Cutting to the point, i need to compare the createdAt date with the Time.Now and display a text saying “5 mins ago” and if it more than a week ago, display the date.
how i can do that?
What do you mean you can’t create a new date? What exactly is the problem?
Were you able to do this with the old DateTime
class, and if so, how?
Future sneak-peek: In the JavaScript layer coming up, there will be plenty of JS libraries that can be used for this. 
You could use parser for OffsetDateTime. It does not support milliseconds yet.
There is Period.Between method for calculating date difference.
var result = OffsetDateTimePattern.GeneralIsoPattern.Parse("2015-06-11T17:53:54Z");
if (result.Success)
{
var period = Period.Between(result.Value.LocalDateTime, ZonedDateTime.Now.LocalDateTime);
debug_log(period); // P6DT22H35M28S773s4842t
if (period.HasDateComponent)
{
// period has non-zero Years, Months, Weeks or Days
}
else
{
// period has non-zero Hours, Minutes, Seconds or Milliseconds
}
}
thanks for all the replies.
i will post the code when i finish it
{
string dateString="";
var PostedDate = PostedDateStr.Split('T');
var FechaPosted = PostedDate[0].Split('-');
var TimePosted = PostedDate[1].Split(':');
var secsplit = TimePosted[2].Split('.');
TimePosted[2] = secsplit[0];
int dateAno;
int dateMes;
int dateDia;
int dateHora;
int dateMins;
int dateSecs;
int dateMills;
Int.TryParse(FechaPosted[0], out dateAno);
Int.TryParse(FechaPosted[1], out dateMes);
Int.TryParse(FechaPosted[2], out dateDia);
Int.TryParse(TimePosted[0], out dateHora);
Int.TryParse(TimePosted[1], out dateMins);
Int.TryParse(TimePosted[2], out dateSecs);
Int.TryParse(secsplit[1], out dateMills);
var datePosted = new LocalDateTime(dateAno,dateMes,dateDia,dateHora,dateMins,dateSecs);
var dateNow = ZonedDateTime.Now.ToInstant().InUtc().LocalDateTime;
var period = Period.Between(datePosted, dateNow);
if(period.Seconds>0){
string prural="seconds";
if(period.Seconds==1){
prural="second";
}
dateString = period.Seconds+" "+prural;
}
if(period.Minutes>0){
string prural="Minutes";
if(period.Minutes==1){
prural="Minute";
}
dateString = period.Minutes+" "+prural;
}
if(period.Hours>0){
string prural="hours";
if(period.Hours==1){
prural="hour";
}
dateString = period.Hours+" "+prural;
}
if(period.Days>0){
string prural="days";
if(period.Days==1){
prural="day";
}
dateString = period.Days+" "+prural;
}
if(period.Months>0){
string prural="months";
if(period.Months==1){
prural="month";
}
dateString = period.Months+" "+prural;
}
if(period.Years>0){
string prural="years";
if(period.Years==1){
prural="year";
}
dateString = period.Years+" "+prural;
}
HoraMovie.Content = dateString;
}