Marketo - REST API datetime field is wrong - marketo

I sent the following string to Marketo REST API to be set as the value of a datetime field:
"2010-05-07T15:41:32"
But Marketo displays it as:
May 6, 2010 8:00 PM
Is there something i'm missing?

It is always a bit tricky to deal with DateTime properly.
Most probably there are two, but related issues here:
The format of the datetime string you are using is not exactly the format that Marketo expects.
You are living in a timezone that is different to the internal timezone Marketo uses.
Luckily, you can easily overcome this issue.
The exact format for the datetime string should follow the ISO 8601 standard, as it is described in the Field Types section of the documentation. An important part of that specification is the timezone offset, which follows the “normal” datetime part as the difference to Greenwich time in the form of ±hh:mm. So, depending on your timezone, your date string should look like somthing like this: 2017-05-08T08:08:08+02:00. (Where +02:00 is for Central Europe.)
In case you are using PHP, the easiest way to have this format is by using the c full Date/Time format, like so:
$date = new DateTime('2010-05-07 15:41:32', new DateTimeZone('Europe/Budapest'));
$dateString = $date->format('c');
var_dump($dateString);
// outputs: '2017-05-08T08:08:08+02:00'

Related

Compare two dates using Date component only disregarding time

In C#, typically you can use DateTime.Today to get today's date disregarding the time component (e.g. the time component would be at midnight basically).
How do I do that using Luxom library?
I understand you can write DateTime.local() to get a Date object with current Time included, but is there no simple way to effectively disregard the time component so that I can perform a comparison with another Date object?
I can't find any relevant information in the Luxon documentation, though I may have missed something.
In standard JS, this would do it:
new Date(new Date().setHours(0,0,0,0));
But that seems awkward?
You can startOf('day') to set midnight to given DateTime:
"Set" this DateTime to the beginning of a unit of time.
then you can use toJSDate() to get the equivalent Javascript Date or other method like toISO, toISODate(), toFormat() etc to get the string representation of a DateTime.
Example:
const DateTime = luxon.DateTime;
console.log( DateTime.local().startOf('day').toJSDate() );
<script src="https://cdn.jsdelivr.net/npm/luxon#1.25.0/build/global/luxon.js"></script>
If you need to compare Luxon objects have a look at Comparing DateTimes section of the manual.
DateTime.local().toISODate();
This gave me what I wanted.

Date format in lotus notes

I have a lotus notes field which should save the date/time in the GMT format,
for that I used
Dim timenow As Variant
timenow = Now()
Dim dateTime As New NotesDateTime( timenow )
doc.abc = dateTime.GMTTime
This will set the field 'abc' to have the date and time in GMT. But now I am having issues with the date format. In my system it saves it in the format 10/28/2016, but for other users whose system date format is different, it saves it in the format 28.10.2016. I need to force the date format to be 10/28/2016, I tried used format function
doc.abc = Format(dateTime.GMTTime, "m/d/yy h:nn")
The above code gives the date and time in GMT, but doesn't change the date format.
You are wrong in the assumption, that the date is SAVED in that format.
Date items in the backend are number- items. They store the date as number, the integer part is the day, the fraction part is the time of the day (day 0 is 12/31/1899 00:00)
Then the setting in the client determins, how the client displays the date.
In the properties of the item you usually define "Client" as display format, but you could fix the display of the date to a specific form.
But usually this is NOT necessary, and every german will not like the "reversed" order of english / american time formatting.
This will only be a problem, if you construct a text from that date, as #Text() will convert it using the clients format.
I guess, that your problem is not in the "saving" of the item, but somewhere else in your code, where you interpret the date as text, and this is always a problem.
What type of field is it? If it's a date field, the Notes client will use the user's local date format.
If you want to use a specific format, you can use a text field instead, but of course then the time won't adjust to the user's local time zone.
The way to get the best of both worlds is to store the date in date field, but use a computed-for-display field to show it in the user's current timezone, but in exactly the format that you want.
Most people use a NotesDateTime object to set the date in a field
Dim ExpiryDate As New NotesDateTime(Cstr(Today))
Even if the field in the form uses a specific format, the date like 2019-09-08 can mean 8th september 2019 or 9th august 2019 depending of the LocalDate setting
To avoid this behavior, you need to force the format in your NotesDateTime Object
Like this
Dim ExpiryDate As New NotesDateTime(Format$( Today, "yyyy-mm-dd "))

Specifiy date type used by fullcalendar

The date/time format fullcalendar uses is kind of weird. I want to specify during the created of the calendar or somewhere in the parameters a datetime of MM/DD/YYYY HH:MM PM/AM. Is there a way I can do this. I read about formatdate, but didn't get any information about this
fullCalendar has "parseDate" and offers three methods:
The string may be in ISO8601 format, IETF format, or a UNIX timestamp (in either integer or string form).
Your "MM/DD/YYYY HH:MM PM/AM" seems not to match one of them.

How can I get an ISO date (not localized) from a PloneFormGen results template?

How do I get an ISO date (2010-01-01 00:00:00), in addition to the localized date, in a PloneFormGen mailer template?
Do you want this for the current date/time, or for a date/time submitted via the form?
Regardless, if you have a Zope DateTime instance, you can get an ISO representation like this:
>>> mydate.ISO()
If you want it in UTC, it's easy to convert it:
>>> mydate.toZone('UTC').ISO()

How to trim datetime string to its minute in GridView?

I have bound fields in GridView to some dateTime property of data objects. The fields are displayed to the seconds level. It looks like 2009-2-3 18:00:00 PM.
I just want it displayed to the minutes, e.g 2009-2-3 18:00.
What is the best way to do this?
Edit:
I find use DataFormatString="{0:g}" is fine for me.
The format is 2009-2-3 6:00 PM.
Although you have found a solution, here's some additional information:
You can find a list of all standard date and time format strings (such as "g") on this page in MSDN: Standard DateTime Format Strings.
And if do not want to use one of the predefined formats, there is also a page about Custom Date and Time Format Strings. For example, to get a date exactly in the format you used in your question ("2009-2-3 18:00") you could use the format string "yyyy-M-d HH:mm".
Before using a custom format string, remember that using the standard (predefined) format strings has the advantage that it automatically takes into account the current culture (regional settings). So if you want to display the date to users, probably a predefined format will be the better choice.

Resources