Date format in lotus notes - datetime

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 "))

Related

How to add time to schema event type

My startDate looks like this 03-03-2020 but I need to add time as well. I have checked some example schema from other sources and have come across something similar:
2020-03-03T12:45:00+01:00
I have two concerns:
Does the time format matter? My format is dd-mm-YYYY. The second example format is different. Is there any problem having it either way?
How do you properly add the time time to the startDate property. Is the last extension the TimeZone e.g +03:00 or should you use the Universal Time zone then include your Timezone (Time offset).
Please help clarify.
I have two concerns: Does the time format matter? My format is
dd-mm-YYYY. The second example format is different. Is there any
problem having it either way?
If you check the description of the startDate property then there you will see the following information:
The start date and time of the item (in ISO 8601 date
format).
If you follow the specified link, then in the Wikipedia article (in the right panel) you can see the following time format:
Date 2020-03-04
In order to establish a machine-readable format, you can use an HTML element such as time with datetime.
======================================
How do you properly add the time time to the startDate property. Is
the last extension the TimeZone e.g +03:00 or should you use the
Universal Time zone then include your Timezone (Time offset).
Indicate time in ISO format with a time offset, e.g., if you are located in the Canadian province of Yukon then you can use a time zone indication such as 2020-03-04T05:16:15-08:00.
In Sweden, I have Central European Time with a time offset of +1 hour and summertime +2 hours. So at the moment in Sweden, I can use a time format such as 2020-03-04T05:22:16+01:00. However, the Sweden summertime will be in a format such as 2020-07-04T05:22:16+02:00

Marketo - REST API datetime field is wrong

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'

Adding a number to a date

What I need to do is in my program i need to add the Arrival DATE and the Nights staying together and have it display into another textbox called Departure date. The format for the arrival date will be in the "##/##/##" context and the nights staying is an integer between 1 and 14.
I have all of the code for the rest of my program completed, I just do not know how to do this. I dont know how to take an integer and add it to a date so in the display box, after they are added together, it displays a date X amount of days after the arrival days. Where X is the Nights staying.
I Will greatly appreciate any help with this.
Use DateTime.AddDays to add number of days in the DateTime object like:
DateTime arrivalDate = new DateTime(2014,03,10);
DateTime departureDate = arrivalDate.AddDays(1); // Add One day
To get the formatted Date back use ToString with Custom DateTime Formats
string formattedDate = departureDate.ToString("dd/MM/yy", CultureInfo.InvariantCulture);

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 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