1
I have a website here that is pipocando problems more and more. It was done in ASP CLASSIC by another programmer and I’m more lost than anything else in this messy logic.
The problem is this: the site is a news portal, in which, as all posts are made, appears in the corner for how many hours the publication was relived. The problem is, you’re not showing those hours.. It starts counting the hours from the moment the user (anyone else enters the site) enters the site, so counting from the hours that the user is in the portal. Follow picture:
<div class="col-xs-12 titulo-editoria p-a-0" style="border-color:@Model.FK_NoticiaTopo2.TbCategoria.Cor">
<span class="nome-categoria" style="color:@Model.FK_NoticiaTopo2.TbCategoria.Cor">
@Model.FK_NoticiaTopo2.TbCategoria.Nome
</span>
<span class="chapeu-topo">- HÁ @Model.FK_NoticiaTopo2.DataPublicacao.Value.Subtract(DateTime.Now).Hours HORAS</span>
</div>
What could you do to solve this? I thank you!
EDIT
Hello Lucas, welcome to the site. Posting only images makes our help a little difficult. Would you like to post the code instead of the image?
– Randrade
Taking advantage, remove the part of
.Subtract(DateTime.Now).Hours
and see if it returns any value.– Randrade
Also remembering that this way you have a big problem, because if the person access the site before 1 hour, will always show 0. If you want to remedy this problem, you can take a look at this question and in his answers.
– Randrade
<div class="col-Xs-12 title-editor p-a-0" style="border-color:@Model.Fk_noticiatopo2.TbCategoria.Color"> <span class="name-category" style="color:@Model.Fk_noticiatopo2.TbCategoria.Color"> @Model.Fk_noticiatopo2.TbCategoria.Name </span> <span class="top hat">- THERE @Model.Fk_noticiatopo2.DataPublicacao.Value.Subtract(Datetime.Now). Hours HOURS</span> </div>
– Lucas Polizeli
Hey Lucas, I’m glad you want to improve the post. But the ideal is you [Dit] the post and post that information there. But the most important thing is to know the exact value that
@Model.FK_NoticiaTopo2.DataPublicacao
is returning. Could post this value too?– Randrade
I made an edit in the post that shows an image of how it is after the removal of . Subtract(Datetime.Now). Hours
– Lucas Polizeli
The date says the time is 23/08/2017 00:00:00. That is, either it was a big coincidence (I doubt) or your code is not saving the time. You can check at the bank or elsewhere if the time is being saved at the time of post creation?
– Randrade