Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9142749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:51:16+00:00 2026-06-17T09:51:16+00:00

I currently have the standard Datetime using AM / PM . I wish to

  • 0

I currently have the standard Datetime using AM/PM. I wish to have 24H Display. Searching the web gave me alot of options with String.Format() option.

Problem is that this creates a string object to display the date. I need to use a datetime object because it is used in a table and the date column must be able to be sorted (asc/desc). The table is of a GridView Object.

Code Example

Currently the code shows the date as follows 8/21/2009 11:28:36 AM. I a perfect situation it would show as 11:28:36 21/8/2009. I know i can get that result with the following code.

date.ToString("dd/MM/yyyy HH:mm:ss");

Problem is that this is a string. The string get’s placed into the table and if i sort the date column it will first sort on day instead of year.
showing the followin descending column.

21/8/2009 11:28:36
20/1/2013 15:55:23

To correctly be able to sort the column the inserted objecttype should be DateTime. the object type is forced by the following code.

dateTable.Columns.Add(new DataColumn("Date", typeof(DateTime)));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:51:17+00:00Added an answer on June 17, 2026 at 9:51 am

    According to this article you can use a boundfield like so:

    <asp:boundfield datafield="Your_Date_Column" dataformatstring="{0:MMMM d, yyyy}" htmlencode="false" />
    

    You can then simply use this format string:

    "HH:mm"
    

    Where capital H renders the 24-hour time, as opposed to a small h which would render a 12-hour time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have this method in a standard web service: [WebMethod] public void addGame(int
I currently have 2 projects, one is a standard ASMX web service and the
We currently have a form with the standard multi-select functionality of here are the
I have tweaked the standard jelly template to display the current test results in
Currently have a drop down menu that is activated on a hover (from display:none
We have a data driven ASP.NET website which has been written using the standard
I have a rails application where I store created_at as datetime (standard). I am
I currently have the standard dev eclipse 3.5.2, but now need to do some
We currently have a product that uses Sharepoint and a number different Web Part
I currently have a a pretty standard jqgrid that I would like to change

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.