Set Value of form field as current date in JHipster - html

We are trying to set default value of form field as current date in Jhipster.
Now, jhipster provides a moment format to a date which is eventually a ngbdatepicker. If we try to change the input type to "date" we cannot assign moment instance with date. If we typecast new date object as moment, the template shows error messages.
Please let us know if its possible.
Thanks in advance.

I have found a way around to solve this problem:
All you need to do is typecast your standard date object to moment after importing the moment obviously:
import * as moment from 'moment';
and typecast your field something like
your_form_field = moment(new Date());
Eg:
this.mstSite.siteUpdatedOn = moment(new Date());
Hope this solves your problems.
...Cheers...

Related

osisoft updating values ​with python

I want to get the data from Excel and update the values ​​of the data between certain dates in the osisoft system. But I don't know how to code AfTimeRange.
I get the error "value cannot be converted to OSIsoft.AF.Time.AFTime".
enter image description here
Good news: You've constructed your [AFTimeRange] correctly!
Notice that the error being thrown is not by the [AFTimeRange] constructor, but from something else.
The issue is that you are trying to set the 'Timestamp' attribute [OSIsoft.AF.Time.AFTime] to a value of type [OSIsoft.AF.Time.AFTimeRange], and so it's failing. A PI event has a single timestamp, not a time range.
I'm not familiar with Python, but it should work if you input the value as an AFTime object using its string constructor, assuming you're intending to use yesterday midnight as your timestamp:
val.timestamp = AFTime("y")
See the documentation on AFTime for more detail.

How to save Timestamp in Firebase in Appsmith app or using JSON?

I am trying to save the date/time in Firebase in timestamp format. I have referred answers from below posts.
How to get current timestamp of firebase server in milliseconds?
https://www.reddit.com/r/Firebase/comments/n32ys2/how_can_i_save_the_values_in_the_datepicker_as/
I have tried saving data by adding different date formats in Body but it is ultimately getting added as a string or number depending upon string or timestamp.
Does anyone have idea how to send the date to Firestore using JSON or anything using which i can directly add it to Appsmith app?
As of now Appsmith supports adding a server timestamp to any field in Firestore. Server timestamp is the timestamp provided by the Firestore server when that particular query was executed.
e.g. if there is entry like
{
id : {name: foo, lastUpdated: ts}
}
then the lastUpdated field could be updated with the last update timestamp via setting the Timestamp Value Path to ["id.lastUpdated"]
Please checkout the video here and comment by user tazmaniax to understand more: https://github.com/appsmithorg/appsmith/pull/3693
Reference:
https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FieldValue#serverTimestamp()
Appsmith's documentation for this is under progress and will be available on the Appsmith documentation site soon. Apologies for not putting it over there sooner.
For any other query or help please join Appsmith's discord channel
I have the impression that there is an error with the Firestore and Appsmith connector.
I have tried different combinations and if you do not send a string, int or bool in the json request, errors are generated.
However Appsmith added an additional field for handling timestamp (now)

'ts' Number Field in Database? (ex. 1428881039)

Thanks to outsourced development, each row in many of my tables has an undocumented field called ts with values such as 1428881039. This is in addition to an actual created_at timestamp field with values such as 2015-04-12 17:23:59 MDT.
These values are passed to this function before displaying it on the web page:
public static function display($ts, $created_at, $format = self::FORMAT_DETAILS){
if ($ts && Session::has('tz_offset')){
$adminTzOffset = Session::get('tz_offset');
$final = (int)$ts - (int)$adminTzOffset;
return date($format, $final);
}else{
return $created_at;
}
}
I understand that it has something to do with possibly making sure that the date shown is for the user's correct timezone, but it doesn't even seem to work; it ends up showing the wrong time. Obviously I could just display the created_at timestamp, but I understand what this is trying to do here.
Any ideas of what this ts field represents?
Based on the info garnered from the comments, I would say that the ts field is an attempt to record UTC time - since it appears it is 6 hours ahead of your created_at field.
The code itself looks like it is using this $ts value to calculate a corrected timezone based off a session variable. If you're getting incorrect times, maybe the logged in user has an incorrect timezone setup?

Joomla 2.5 Component - Store date/time, display on different timezones

Developing a component for Joomla v2.5, I'm using a table with a mysql timestamp column.
One of the component's settings is the "Timezone". I don't want to use server timezone, as code will run on different servers/timezones and I want to be indepedent. So the idea is to store timestamps in mysql, and display the correct date/time according to the component's parameter. The main drawback is the timezone that mysql server uses, that make the whole situation complicated. So, is there a way to store current timestamp in an universal format in MySQL and display it in the correct way?
The ultimate goal is for the component to be able to display the correct date/time based on the component's parameter, eg. user changes the parameter on the fly, no modification on the database take place, only on the "View"
In order to display the date in the correct timezone I use this:
JHtml::date($date_from_mysql , 'd/m/Y H:i:s', $my_component_timezone_parameter)
Please share your thoughts.
try
jimport ('joomla.utilities.date');
$date = new JDate($mydate);
$curdate = $date->toFormat('%Y-%m-%d %H:%M:%S');
for timezone settings
try http://docs.joomla.org/JDate::setTimezone/1.6
http://www.webamoeba.co.uk/site/index.php/articles-joomla-date-time
or try to override the store method in your table class:
public function store($updateNulls = false)
{
// get date
$date = JFactory::getDate();
// set variable for timestamp
$this->myDate = $date->toMySQL();
return parent::store($updateNulls);
}

Flex DateField and MySQL default date value 0000-00-00

I created a service and callResponder (Via Generate Service Call and Generate Form in Flash Builder 4) that query a MySQL database for a name and a birth date.
My problem is so simple I guess but I haven't been able to find the solution...
When I have an empty date in MySQL (0000-00-00), my binded DateField indicates 1899-11-30
I tried almost everything possible... A custom labelFunction, a custom function called straight after the call to my service to try to handle my data like this.. :
protected function parseDate(date:Date):void
{
if (date.getFullYear() == -1) {
friendbirthdate.selectedDate = null;
} else {
var df:DateFormatter = new DateFormatter;
df.formatString = 'YYYY-MM-DD';
friendbirthdate.selectedDate = date;
}
}
Unfortunately, this works only partially. When I try to update this same form in the database I get disconnected. I'm missing something here and would greatly appreciate a tip or two :-)
THANKS!
I recommend that you store NULL for unknown dates, as opposed to '0000-00-00'. NULL is a more accurate value in this case.
If you want to store it as NULL and display it as a different value you can do something like this:
SELECT COALESCE(date_column,'0000-00-00') as formatted_date
FROM your_table
Don't know if it will help somebody but I had trouble to insert values from a form, containing a DateField. That Form has been generated through the Flash Builder Generate Form tool.
The problem is that the service generated by Flash Builder expect a Date Object, no matter what... If you submit the form without selecting a date in the DateField, the service call crashes.
Let's have a look at a part of the generated sample service (Create and Update functions), we can see that PHP is expecting to transform a Date Object to a String like this :
mysqli_stmt_bind_param($stmt, 'sss', $item->friendname, $item->friendlastname, $item->friendbirth->toString('YYYY-MM-dd HH:mm:ss'));
First of all, be sure that your Date field in MySQL has as NULL default value.
Then alter the create and update functions like this :
if ($item->friendbirth == null)
$friendbirth = null;
else
$friendbirth = $item->friendbirth->toString('yyyy-MM-dd HH:mm:ss');
mysqli_stmt_bind_param($stmt, 'sss', $item->friendname, $item->friendnickname, $friendbirth);
This way, the service call script won't try to do kinda null->toString('...')