function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
oofoofoofoofoofoof 

How to re-format date/time field?

I have a custom link on a page that takes me to the edit page of another custom object. I want to pre-populate the fields on the new page with data from the originating page. I'm having trouble with a date/time field. The receiving field needs the date/time to be formatted as MM/DD/YYYY HH:MM AM/PM,
but when I use the merge field from the sending page as follows:
 
parent.frames.location.replace(...&00NT0000000upfz={!Event.ActivityDateTime}...
 
the date in the receiving field shows up as MM/DD/YYYY, so I get "Error: Invalid Date and Time" in the receiving field.
I tried assigning {!Event.ActivityDateTime} to a javascript variable, but the assignment does not produce the Date object. How do I format the sending date/time to be acceptable to the receiving field?
 
The_FoxThe_Fox
Hello,

Rapidly you have to store your event in a javascript stringa and then try to create a date with the correct parameters as your date type wanted.

Try this at first and give the results

Cheers
oofoofoofoofoofoof

assigning to string gives the same result.

var x = "{!Event.ActivityDateTime}"; alert(x)

shows up as "3/1/2007"

The workaround I am using is to extract the ActivityDateTime from the DB using soql, creating a JS Date, assigning UTCHours() UTCMinutes() to the JS Date and then extracting time in localtime. It works, but is ugly.