In the article called "Getting BlogEngine.NET To Work With The Local Time Zones"I described how to convert the times of the posts to the local time zones of users relying solely on JavaScript. However I got a complaint that if JavaScript is disabled for some reasons, then no date and time are displayed.
It can be fixed, I’ll explain how, but in this case – if JavaScript is disabled, the time will be in GMT, so just put the following code to PostView.ascx
that basically outputs the time in GMT and if JavaScript is enabled it replaces a GMT time with a local time.
<span id="postDate_<%=Post.Id %>" class="pubDate">
on <%=Post.DateCreated.ToLongDateString() + " " +
Post.DateCreated.ToShortTimeString() %> GMT
</span>
<script type="text/javascript">
$("postDate_<%=Post.Id %>").firstChild.nodeValue =
"on " +
ConvertToLocalDate(
'<%=Post.DateCreated.ToLongDateString() + " " + Post.DateCreated.ToShortTimeString() %>'
);
</script>
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way. My personal thoughts tend to change, hence the articles in this blog might not provide an accurate reflection of my present standpoint.
© Mike Borozdin