• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

New to CF and seeking help with DateTimeFormat

New Here ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

Hi there,

I'm new to CF and trying to format a timestamp but no matter what I try I am unable to get the DateTimeFormat function to work successfully so I am hoping that some one with more experience might be able to quickly identify what I am doing incorrectly.

Goal: trim the timestamp

<cfscript>

     unformattedTime = "{ts '2018-11-05 12:13:50'}";

     formattedTime =  DateTimeFormat(unformattedTime, "yyyy-mm-dd HH:nn:ss");

       writeOutput(formattedTime);

</cfscript>

Expected Output: 2018-11-05 12:13:50

Actual output: nothing

Views

339

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

If you paste your example code into cfFiddle you will see it works as expected, however, you should probably use the CreateDateTime() function to initialize the unformattedTime variable.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

Thank you for your reply. It is very much appreciated. I just realised that the reason its not working is that Im using an older version of CF that doesn't support the DateTimeFormat so I had to use the separate DateFormats and timeFormats to resolve it. Thanks again.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 02, 2019 Feb 02, 2019

Copy link to clipboard

Copied

LATEST

Please mark the correct answer. It will help someone else in future.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation