Results 1 to 6 of 6

Thread: DateTime Formatting

  1. #1

    DateTime Formatting

    Hi,

    I'm trying to extract the different parts of the time from a string.

    But i'm having a problem, I need to be able to set the formatting to 09:00 instead of 9:00 so that I can process it more accuratley.

    Could someone show me how to format it?

    Please...

    Thank you.
    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

  2. #2
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    DateTime Formatting

    Daft question time...

    Are you reading the date/time from user input or from the system clock?

    If its the later there are procedures that extract the component parts for you (decodeTime and decodeDate). If its the former and its a gui, why not use the date/time selectors?

    As I said... probably a daft question... depends on what you want to achieve.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  3. #3

    DateTime Formatting

    sorry I was so daft

    I was pulling it from the system time.
    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

  4. #4
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    DateTime Formatting

    Quote Originally Posted by Voltrox
    sorry I was so daft

    I was pulling it from the system time.
    You misunderstand me hon.... I wasn't calling you daft. I was putting a rider on my question in case it was silly. Its difficult to know how experienced people are and some people can be offended if you ask them simple questions.

    If you are using 'now' to get the time, decodeDate and decodeTime should be perfect for your needs.
    :: AthenaOfDelphi :: My Blog :: My Software ::

  5. #5

    DateTime Formatting

    You can also set the time format using sysutils.
    Code:
     SysUtils.ShortTimeFormat&#58;='hh&#58;mm&#58;ss';
     SysUtils.longTimeFormat&#58;='hh&#58;mm&#58;ss';
    You can put that anywhere in your code, like on form create. The above will force windows to use 24 hr clock, 2 digits for each part.

    I am sure you can rearrange that so it gives desired output in the first place and then extract?

    Sysutils works with date and time, as well as the joining character. You can set that to something like "-" or "." for example.

    Code:
    sysutils.TimeSeparator&#58;='&#58;';
    and for dates :

    Code:
     SysUtils.shortDateFormat&#58;='dd/mm/yyyy';
      SysUtils.LongDateFormat&#58;='dd/mm/yyyy';
    etc

  6. #6

    DateTime Formatting

    Thank you.

    That was very helpful seiferalmasy.

    Thank you Athena.

    Nicholas.
    <br />
    <br />Please join: http://holzstukka.proboards81.com

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •