Welcome, Guest
  • Author Topic: Date Formatting using the DataSet component  (Read 4766 times)

    samson1

    • Server what's that
    • *
    • Posts: 44
      • View Profile
    I am able to correctly format the date from an xml file as DD-MM-YY HH:NN, but is there a way to format it so that it appears like this:

    Sun Jan 3 2005, 8:23pm

    If not, how about:

    Sun Jan 3 2005, 20:23

    Help would be greatly appreciated. I have looked all over for an answer but not found any!

    Geoff

    samson1

    • Server what's that
    • *
    • Posts: 44
      • View Profile
    Re: Date Formatting using the DataSet component
    « Reply #1 on: 01/14/07, 03:25 »
    Hi, I posted this a little over a year ago, and have had no answers (don't worry, I have had a few other jobs in the meantime ;-) ).  However, I would still like an answer if anyone knows it.

    I have spent many hours trying to figure out how to format dates using the DataGrid component, but I remain baffled and unsuccessful.  Very little documentaiton out there (-- perhaps none?), at least for those of us who aren't experts.

    I am returning dates from a mySQL db, and trying to pass them through the xml connector on to the datagrid to display in this format:

    Sun Jan 3 2005, 10:23pm

    Is it possible?  If so, a short tutorial or step by step process would be helfpul.

    Thanks again.  This site has been very helpful for other things.

    Cheers,
    Geoff



    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Date Formatting using the DataSet component
    « Reply #2 on: 01/14/07, 06:03 »
    You can access every single part of a date via the date object.
    Formating is then just a bussines of collecting and writing a string.

    date.getFullYear() gives you the 4 digit year, date.getDate gives you the day etc.

    Just be aware: getMonth delivers you a pointer to an array - which means - January=0 -> December=11 ;)
    happy flashing
    8)
    Ronald

    samson1

    • Server what's that
    • *
    • Posts: 44
      • View Profile
    Re: Date Formatting using the DataSet component
    « Reply #3 on: 01/14/07, 06:38 »
    Hi Ronald,

    Thanks for the reply, but that seems a little beyond me.  I am simply using the drag and drop components along with the Component Inspector.  I have the whole thing working quite well, but just can't format the dates properly, as there is so little documentation.  Any help in that area much appreciated.

    Alternatively, if you can show me how/where to write the code that intercepts these components, happy to try that.  I am passing in via an XML connector a date in the format

    date('d-m-Y, H:i:s',$objRs[$i]->start_time)

    Thanks,
    Geoff

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Date Formatting using the DataSet component
    « Reply #4 on: 01/14/07, 07:39 »
    after you are providing the date via php date function, you can format it at the server side.

    Look into the php help, to find all the different ways of formating a date.
    The date function in php is realy the best alternative formating a date string :)

    d-m-Y means day dash month dash full year
    happy flashing
    8)
    Ronald

    samson1

    • Server what's that
    • *
    • Posts: 44
      • View Profile
    Re: Date Formatting using the DataSet component
    « Reply #5 on: 01/14/07, 07:42 »
    Thanks, but as I understand, passing the date in as a string to the DataGrid prevents it from being sortable?

    Geoff

    Ronald Wernecke

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 6203
      • View Profile
      • Professional Support
      • Email
    Re: Date Formatting using the DataSet component
    « Reply #6 on: 01/14/07, 08:32 »
    this is not realy right - you sort them as string - this is tha standard behaviour anyway.
    happy flashing
    8)
    Ronald

    samson1

    • Server what's that
    • *
    • Posts: 44
      • View Profile
    Re: Date Formatting using the DataSet component
    « Reply #7 on: 01/14/07, 19:04 »
    Ronald,

    Thanks.  If it's a string, Fri 19-01-07 will alphabetically precede Sun 14-01-07, won't it?

    Geoff

    Andresss

    • Systems Administrator
    • *****
    • Posts: 738
    • check me out at www.asb-labs.com/blog
      • View Profile
      • asb-labs
      • Email
    Re: Date Formatting using the DataSet component
    « Reply #8 on: 01/14/07, 21:49 »
    hi samson1!! althought you insert your dates and sort them with the sorting methods, you will never have them correclty sorted, i have thought it and well i hope it helps you:

    why don't you use the next format for the dates for instance 07-01-19 Fri
    now ´honestly i don't know if the "-" will be ignored

    cheers!!
    halemos de flash en español!....wondering about crazy flash experiments?

    samson1

    • Server what's that
    • *
    • Posts: 44
      • View Profile
    Re: Date Formatting using the DataSet component
    « Reply #9 on: 01/14/07, 21:54 »
    Thanks for the suggestion, but the site is for the public, and a reverse order for the date format might be a little confusing. 

    I would like to include the name of the day, e.g. 'Sun" if I can figure out how to format it from a a date ;-)

    Thanks anyway.
    Geoff