Skip to main content
Participant
August 8, 2006
Question

Date time formatting issues!!!!

  • August 8, 2006
  • 2 replies
  • 261 views
guys,
I am trying to format date and time in the same variable. heres my code...

<cfset dtimes = LSDateFormat(now(),'YYYY-MM-DD h:mm:ss')>

the problem is, that it gives me the year month and day correctly.... the hour correctly, but where the minute is supposed to go, it gives me the month again (which makes sense cuz obviously its the same characters)... and then seconds are ok too. how do i fix it so it gives me the correct minutes? Thanks in advance!!!!
JE
    This topic has been closed for replies.

    2 replies

    Inspiring
    August 9, 2006
    johnegbert wrote:
    > guys,
    > I am trying to format date and time in the same variable. heres my code...
    >
    > <cfset dtimes = LSDateFormat(now(),'YYYY-MM-DD h:mm:ss')>

    if you're doing i18n work i would strongly recommend against custom formats, if
    you ever have to parse these back to datetime objects you probably won't
    succeed. use the java standard styles (FULL-->LONG-->MEDIUM-->SHORT) instead.
    Inspiring
    August 8, 2006
    A limitation of CF functions there is not a single date & time format
    function you have to combine the two.

    <cfset dtimes = LSDateFormat(now(),'YYYY-MM-DD') & ' ' &
    LSTimeFormat(now(),'h:mm:ss')>



    johnegbert wrote:
    > guys,
    > I am trying to format date and time in the same variable. heres my code...
    >
    > <cfset dtimes = LSDateFormat(now(),'YYYY-MM-DD h:mm:ss')>
    >
    > the problem is, that it gives me the year month and day correctly.... the
    > hour correctly, but where the minute is supposed to go, it gives me the month
    > again (which makes sense cuz obviously its the same characters)... and then
    > seconds are ok too. how do i fix it so it gives me the correct minutes?
    > Thanks in advance!!!!
    > JE
    >