How to post for how many hours the post has been posted?

1

I have a site here that is popping 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, it appears in the corner how many hours the publication has been relayed. The problem is that, it is not showing these hours .. It starts counting the hours from the moment the user (any other person enters the site) enters the site, being thus, counting from the hours that the user is in the portal. The following image:

<divclass="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? Thanks!

EDIT

    
asked by anonymous 24.08.2017 / 05:32

1 answer

1

According to the DateTime.Subtract documentation you could flip the date values that makes your block as follows:

<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Á @(DateTime.Now.Subtract(Model.FK_NoticiaTopo2.DataPublicacao.Value).Hours) HORAS</span>

    
24.08.2017 / 14:38