Hi guys,
how to convert date time : " 6/15/2009 1:45:30 PM" to "2009-06-15T13:45:30.0900000" using x++
*This post is locked for comments
you should check out the DateTimeUtil class, it has several methods to manipulate date/time. Especially the DateTimeUtil::toFormattedStr method will help you out.
This code will print 2015-12-04T09:59:24, is that close enough?
static void DateTest(Args _args) { UtcDateTime dateTime = DateTimeUtil::getSystemDateTime(); ; print DateTimeUtil::toStr(dateTime); pause; }
Hi tom,
i tried this ..but not working may be syntax problem.
dateTimeUTC = DateTimeUtil::utcNow();
regularTime1 = DateTimeUtil::toStr(dateTimeUTC );
Hi Rudi,
Thanks ..its working perfectly....
thanks a lot
Hi,
if you need a special format, you can try System.DateTime.
https://msdn.microsoft.com/en-us//library/8kb3ddd4%28v=vs.110%29.aspx
static void SystemDateTime(Args _args) { UtcDateTime dateTime = DateTimeUtil::getSystemDateTime(); System.DateTime sysDateTime; ; sysDateTime = dateTime; print sysDateTime.ToString("yyyy-MM-dd"); print sysDateTime.ToString("MM/dd/yy H:mm:ss zzz"); pause; }
Michael
Thanks Rudi Hansen,
I was looking to convert a date field to string format "2018-04-11T14:26:04"
utcdatetime datetime1 = DateTimeUtil::applyTimeZoneOffset( DateTimeUtil::newDateTime(MYDATEFIELD, 0), DateTimeUtil::getClientMachineTimeZone());
DateTimeUtil::toStr(datetime1)
Thanks
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Community Member 4
Martin Tocauer 4
Nayyar Siddiqi 2