Flatpickr convert numbers as dates

I’m using the calendar icon flatpickr next to manual search input but I can’t solve a problem
When I want to do a manual search with product code “1636835408” it converts “1638-11-08” as a date
How do I disable this conversion?

Date searches when I select calendar
So, all others are working fine

        <div class="smallfont flatpickr" data-allow-input="true" data-wrap="true" data-click-opens="false" style="float:right; padding-top: 6px;padding-right: 6px;padding-bottom: 5px;">

            <a data-clear="" title="İçeriği Temizle"><img alt="Temizle" src="images/x.png" style="width: 18px; height: 18px; cursor: pointer;" /></a>
            <a data-toggle="" title="Bir Tarih Seç"><img alt="Tarih Seç" src="images/calender.png" style="width: 19px; height: 19px; cursor: pointer;" /></a>

      <input data-input="" type="text" autocomplete="off" class="bginput" id="search" list="aranacaklar" placeholder="İçerik Ara / Çift Tıkla">

	flatpickr(".flatpickr", {
		"locale": "tr",
		disableMobile: true,
		allowInvalidPreload: true,
		dateFormat: "Y-m-d",
		enable: [ <?php echo $selected_dates; ?> ]

Example enter this number and click on the blank field convert to date format How can I disable this conversion?

A calendar plug-in is designed to return formatted dates, so you get what you asked for.
Just make it a standard text input field. There is no OFF on a plug-in. Maybe you could create one,
but, doubt it. You could use a hidden text field and copy everything into that using a javascript routine and then use that field as input, but, a lot of work…

Thanks for the answer

from an input field
I’m searching manually
I’m searching in double quotes
I’m searching with the “datalist” option
and I search by date using the calendar icon I added next to it.

I use “time()” as the document number and when I manually enter the document number to search for the document, it finds the document, but when clicking anywhere, the document number changes to date format and the search result will be “The Document Not Found”

I don’t want to make more than one input field but I didn’t quite understand your suggestion.

You should not use time as a doc number. Any two members could duplicate that number.
Unless you check for it previously or make the transactions sequenced. Both ways are horribly tricky.
You could use the member’s ID along with the time. That would solve that issue. Since you have only certain dates inside the picker, why don’t you just use a standard select-drop-down?

But, the flatpickr code is a plug-in and therefore has Javascript and JQuery behind the scenes to covert things to the format you pick. You FORCE it in your code:

dateFormat: "Y-m-d",

You could just remove the dashes in there and it should mix it all together:

dateFormat: "Ymd",

But, that depends if they force a default format or not. I would try that first.

I tried this, but it truncates the numbers as much as the date character

My use of date as document number is just for uniqueness.
I have no idea how to give a document number.
I looked on the internet but couldn’t find anything to understand
All I want is for it to be the shortest possible character and unique
It’s unique because Documents don’t conflict
And the document number doesn’t have to be sequential
I would like to know your suggestion

I added a second entry for the date, I guess there is no solution

Ekran görüntüsü 2021-11-19 201924

Well, Adem, there are many ways to create a document number. Basically, it depends on what you need it for. If you have users that use your system, or even just visitors not logged in, you can create a document number in many ways. Using the date might be a problem because two users can save at the same exact time. It is unlikely but can happen. One simple way is to just use an ID number in your database table that is auto-incremented. Like you do for user id’s or other tables. This number is created when you create the document and just gets loaded from the database table when created. Then, you can use that id number for the filename. Do you understand that logic?

Or, you can create a GUID. A guid is “Globally Unique Identifier” which just means it is a unique number that is not duplicated. A simple routine can create one of these for you. Things like Microsoft’s product key code is an example. I can give you a routine to do that, but, I do not think you need it. You could use your date as-is or add a random number at the end of it to make it unique.

Not sure if this helps or makes it more complicated for you.

I understand very well what you are saying.

Adding the user ID to the document number doesn’t seem right to me because the registered user and the Guest created this document

The database can give an auto-incrementing number like ID to every document, but I think it will be ugly like the example below
I want it to be as short as possible
The document number can be prefixed with a fixed letter such as “AG” but not required
It doesn’t have to go sequentially, but it can be.
It can be like a license number, but I don’t want a dash “-”
I actually like the license number, this could be (without the hyphen)

HUH? You let guest upload documents? That is dangerous! No way to know if it is a real person or robot or hacker that could put in code to damage your site. Make no sense to me to let unknow people upload documents.

Well, you can make up your own GUID with ease. It is just a simple random number set up. I prefer letters, but, numbers can work too. So, if you want to create a GUID, just make it 8 letters long and only capitals, no dashes, no numbers. Simple. There are 26 letters, so 8 letters long would be a huge number of possible documents. More than you would need. And, the only catch is to make sure the GUID does not exist before saving the document.

If you want this type of routine, something like this would work…

$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$filename = '';
for ($i = 0; $i < 8; $i++) {
    $filename = $chars[rand(0, strlen($chars))];
$filename = $filename . ".doc";  //  Add the extension...

Basically, this version is set up to create 8 letters or numbers caps and lower-case. You can change it by removing the numbers if you don’t want them, or the numbers and lower-case if you just want upper case GUID. Then, use the PHP function exists($filename) to see if it is already taken. If not save it. If so, just call the routine again. Easy…

No document upload
I’m using time() to give the document number to the generated price offer
I use it both as a file name and for the quote number above the price quote.
In addition, the offer number is recorded in a column of the database.
Actually time() was working, but when it searched by document number, converting it to date format prevented the search
The problem was solved by making a separate entry for the date, but it would have been better if there was only one entry field.
It is possible that time() conflicts with the same number, but I think the probability is very remote.
If there is such a conflict “it will say that it is already registered with the same number”

Well, Adem, I am still confused on your logic. If you create a price quote and enter it into your database, just create a new GUID for it and store that in another field. And, show it to the user or whoever views it as the date from the database row and use the GUID as the filename if they click on it. Easy to do this way. And, no converting dates which are complicated in some cases.

If you must convert date-time’s into strings, just use the string versions and build it using month(date) . day(date) . year(date) or something simple like that…

Sponsor our Newsletter | Privacy Policy | Terms of Service