issues with Formatdate function in ampscript - salesforce

I have an issue where I want to display only the hh.mm in da-DK from the NOW() function in AMPscript.
I have tried the following two options.
formatdate(Now(),"","HH.mm","da-DK")
This inputs only time but servertime, ex. 03.16
format(Systemdatetolocaldate(Now()),"","hh.mm")
Correct time but the whole string, ex. 12/10/2020 10:16:44 AM
Anyone with some pointers?

I've found a "quickfix" with the set of
SET #redeemedHour = datePart(Systemdatetolocaldate(Now()),"H")
SET #redeemedMinute = datePart(Systemdatetolocaldate(Now()),"minute")
and then concanate

Related

How to get raw date string from date picker?

I'm struggling for hours with this seemingly trivial issue.
I have a antd datepicker on my page.
Whenever I choose a date, instead of giving me the date I chose, it gives me a messy moment object, which I can't figure out how to read.
All I want is that when I choose "2020-01-18", it should give me precisely this string that the user chose, regardless of timezone, preferably in ISO format.
This is not a multi-national website. I just need a plain vanilla date so I can send it to the server, store in db, whatever.
Here are some of my trials, so far no luck:
var fltval = e;
if (isMoment(fltval)) {
var dat = fltval.toDate();
//dat.setUTCHours(0)
fltval = dat.toISOString(); // fltval.toISOString(false)
var a = dat.toUTCString();
//var b = dat.toLocaleString()
}
It keeps on moving with a few hours, probably to compensate for some timezone bias
UPDATE 1:
the datestring is data-wise correct. But its not ISO, so I cant use it correctly. I might try to parse this, but I cannot find a way to parse a string to date with a specific format.
UPDATE 2:
I also tried adding the bias manually, but for some reason the bias is 0
var dat = pickerval.toDate()
var bias = Date.prototype.getTimezoneOffset()// this is 0...
var bias2 = dat.getTimezoneOffset()// and this too is 0
var d2 = new Date(dat.getTime()+bias)
var mystring= dat.toISOString() //still wrong
Thanks!
Javascript date functions can be used,
I assume you are getting in 2022-01-03T11:19:07.946Z format then
date.toISOString().slice(0, 10)
to 2022-01-03
There are 2 ways to get the date string:
Use the moment.format api:
date.format("yyyy-MM-DD")
Use the date string that is passed to the onChange as second parameter
Here is a Link.
I am assuming your code snippet is inside the onChange method. This gives you a moment and a date string to work with (the first and second parameters of the function respectively).
You have a few options. You could set the format prop on the DatePicker to match the format of the string you want. Then just use the date string. Or you can use the moment object as Domino987 described.

Unhandled Rejection (TypeError): formProps.date.getTime is not a function

How can I change hour and minute values to an existing Date variable?
formProps.date: existing Date type variable generated from a date picker that I want to use year value only.
formProps.hour: The hour value that user input separately.
formProps.minute: The minute value that user input separately.
Those three values are to be combined into a new Date variable 'dateWithTime', but it throws an error during copying the date values.
It this a wrong way to copy a Date variable? or is there any better way to make it?
const dateWithTime = new Date(formProps.date.getTime());
dateWithTime.setHours(formProps.hour, formProps.minute);
==== edit ====
the log of
console.log(formProps.date.toLocaleString());
console.log(typeof(formProps.date));
I don't know why your code above doesn't work but the below code worked for me. Could u try to use:
const dateWithTime = new Date(formProps.date.toLocaleString());
(I know it is not an comprehensive answer but I couldn't add a comment due to my reputation :/ )

why cloudlet.getSubmissionTime() & cloudlet.getExecStartTime() in cloudsim returns same value?

i wanted to compute the response time for all cloudlets submitted. for that i am using the following statement:
responsetime = cloudlet.getExecStartTime() - cloudlet.getSubmissionTime();
The problem i am facing is that the two methods cloudlet.getSubmissionTime() & cloudlet.getExecStartTime() returns same value. Please suggest solution for the same
responsetime = cloudlet.getFinishTime()- cloudlet.getExecStartTime()

How to split date string using Selenium webdriver

I'm retrieving text value of last updated time from application.
Output looks like this:
03/02/2016 5:40:78
Time is dynamically changing. By using "get text" I retrieve last updated time and outputting to console.
I want to split data.
Use split function to achieve same. As you can observe there is a space between your Date and Time
String[] DateTime = driver.findElement(By.xpath("Your Locator")).getText().split(" ");
String Date = DateTime[0];
String Time = DateTime[1];
System.out.println(Date);
System.out.println(Time);

cakephp 3 displaying date without time

CakePHP 3: I have a database field which is a DATE (not DATETIME nor TIMESTAMP)
When I display
echo $contact->date;
It will show something like 2014. 01. 06. 0:00. How to hide hours and minutes?
I tried
print $this->Time->format($contact->date, 'Y-m-d');
but I got 2014-0-6
How to get year-month-day?
rrd
Have you tried this?
echo $contact->date->format('Y-m-d');
add in App\Controller:
use Cake\I18n\Time;
Time::$defaultLocale = 'es-ES';
Time::setToStringFormat('YYYY-MM-dd');
You can directly print the date object in any custom date String format by using the inbuilt i18nFormat function.
$frozenDateObj->i18nFormat('dd-MMM-yyyy');
Use Datetime Format Syntax reference for more customization
If need all over the project with specific format you can use
boostrap.php
Cake\I18n\FrozenDate::setToStringFormat('yyyy-MM-dd');
echo date_format($contact->date, 'Y-m-d'); //php format
try
date('Y-m-d',strtotime($contact->date));

Resources