I have date in my log as 09 Jul 2019. I want the timestamp date which comes by default in Kibana to use this date.
I have defined the custom pattern for extracting the date as AV_DATE %{MONTHDAY} %{MONTH} %{YEAR}
.
How do I map this date to #timestamp field?
If you are using logstash try the following:
date {
match => ["AV_DATE", "ISO8601"]
}
or try the following:
date {
match => ["AV_DATE", "ISO8601"]
target => "#timestamp"
}
Related
I want to display the user's last sign-in date in Kotlin but it always returns today's day.
val user :FirebaseUser = FirebaseAuth().getInstance().currentUser!!
val timeStamp : Timestamp = Timestamp(user.metadata?.lastSignInTimestamp!!)
val date = Date(timeStamp.time)
Toast.make(this, date.toString() ,Toast.LENGTH_SHORT).show()
I want to display the user's last sign-in date in Kotlin
To display the user's last sign-in date in a Kotlin "style", please use the following lines of code:
FirebaseAuth.getInstance().currentUser?.metadata?.apply {
val lastSignInDate = Date(lastSignInTimestamp)
Toast.makeText(this, lastSignInDate.toString() ,Toast.LENGTH_SHORT).show()
}
The result will be a Toast message containing the String representation of the "lastSignInDate" object, which is an object of type Date. Let's suppose the user has signed in last time yesterday, the message might look similar to this:
Wed Mar 31 11:20:10 GMT+03:00 2021
If needed, you can also format the Date in a more readable way, as explained in the answer from the following post:
convert epoch time to date
I was creating project in Angular and to format date I decided to use moment.js. But the problem is from the backend I get such format "2020-02-06" thus I decided to use 'MMM DD, YYYY' and I want "2020-02-06" to look like Feb 6, 2020 with this format MMM DD, YYYY. So, to achieve that I have this code
moment(
response.data.projectCreatedDate //this contains "2020-02-06"
).format("MMM DD, YYYY");
BUT the problem is instead of getting Feb 6, 2020 I get 13 May, 2020 which is today's date. Pls can you help, what am I doing wrong?
Moment with empty argument returns current date, and format on top of it returns current formatted date .Your date from server might be undefined, Hence you are the getting current date formatted.
You can also pass custom date for formatting too!
//Formatting an input date
var str = "2020-02-06";
console.log(moment(str, "YYYY-MM-DD").format("MMM D,YYYY"));
//Formatting current date
console.log('Current Date: ', moment().format("MMM D,YYYY"));
//Formatting array of dates
var arr = ["2020-02-06", "2020-01-13"];
var res = arr.map(date => {
return moment(date, "YYYY-MM-DD").format("MMM D,YYYY");
});
console.log(res);
<script src="https://momentjs.com/downloads/moment.js"></script>
Nothing is wrong with moment here, you are getting an empty response inside response.data.projectCreatedDate from your server.
moment("2020-02-06").format("MMM DD, YYYY") //Feb 06, 2020
moment().format("MMM DD, YYYY") //todays date.
Thanks.
I am trying to configure FullCalendar 4.3.1 in Timeline view to display date in UK format in the title and on column headers. I use slotLabelFormat and titleFormat as below:
slotLabelFormat: [
{ day: 'numeric', weekday: 'short', month: 'short'},
{ hour: 'numeric' }
],
titleFormat: {day: 'numeric', month: 'long', year: 'numeric'}
This works, however, it does not choose the order of items so I end up with Mon Dec 31 instead of Mon 31 Dec. Is there a way to set the order or default date format (based on location)? I can't find it in the docs.
Adding the below to calendar parameters resolved it. Thanks all.
locale: 'en-gb'
I want to store the current GMT date and time in ISODate format in mongodb.
Similarly to this
ISODate("2012-07-26T17:43:25.678Z")
I want to store the result in mongodb in the above mentioned format(it should be a ISODate object). How to generate such a format in using php?
I think DateTime will fit into an ISODate, but you might also want to consider http://php.net/manual/en/datetime.setisodate.php.
Use MongoDate: http://www.php.net/manual/en/class.mongodate.php
Example in this page:
<?php
// save a date to the database
$collection->save(array("ts" => new MongoDate()));
$start = new MongoDate(strtotime("2010-01-15 00:00:00"));
$end = new MongoDate(strtotime("2010-01-30 00:00:00"));
// find dates between 1/15/2010 and 1/30/2010
$collection->find(array("ts" => array('$gt' => $start, '$lte' => $end)));
?>
I'm using symfony 1.4 doctrine. I have an output in my database/browser that looks something like this:
Start time: 12:00:00 End time: 05:00:00
Now I want to change this format like this:
Start time: 12:00 pm End time: 5:00 pm
I tried to convert this in yaml in the backend application like this:
apps/backend/modules/reservation/config/generator.yaml
//some yaml code
fields:
startime: { date_format: h:i A }
endtime: { date_format: h:i A }
I use this format but it did'nt work, probably I set in the schema.yml their data types in "time" format:
reservation/config/doctrine/schema.yml
//some yaml code
columns:
startime: { type: time, notnull: true }
endtime: { type: time, notnull: true }
I set my startime and endtime to time format just to get the time value only for my project. I did'nt set it to date type because it will affect my front end application. For example if I input 5:00 the display will be 12:00 am, its because I use date type.
To turn this 5:00:00 to 5:00 pm/am in display, I set it into time data type and I use this syntax like this which I used in showSuccess and Indexsuccess template.
<?php echo date('g:i A', strtotime($reservation_application->getStartime()));
this code will format 00:00:00 into 12:00 am or something. but it doesnt change (00:00:00) in the data base. ONLY in display.
Is there a way to format this 00:00:00 into 12 hr format in the yaml file? Many thanks
When you save a time, it's always stored without any culture information. (And as soon as you're going to create a multilingual website, you'll be glad of that!).
That said, it's best to use the DateHelper when formatting dates in the view. This has a format_date function. When you're using this function, don't forget to set the default_culture in the settings.yml (or set the correct culture in the sfUser).
For example format_date($date, 't'); prints the current time, in the users culture.
For an overview of which patterns you can use, see this page.