daloradius icon indicating copy to clipboard operation
daloradius copied to clipboard

Date Helper format bug

Open momothefox opened this issue 1 year ago • 2 comments

Date helper format needs to be 01 Jan 2023 current format not working with freeradius
failed to parse time string "2023-05-26" bandicam 2023-03-26 09-12-15-399

Freeradius parse date time like this expiration: Account will expire at 'May 28 2023 00:00:00 EET'

momothefox avatar Mar 26 '23 07:03 momothefox

Do you have a Solution?

zu3st-de avatar Sep 08 '23 13:09 zu3st-de

@zu3st-de

If someone can fix this up >> Asking Chat GPT >>>
https://github.com/lirantal/daloradius/blob/a2cbc3685cf7f7856bba178d97adf221159cee10/app/operators/library/ajax/attributes.php#L1

To set the HTML input format to "01 Jan 2023," you can use the following approach:

  1. Change the input type to "text" instead of "date" since the standard date input doesn't allow custom date formats.

  2. Use a JavaScript library, such as jQuery UI Datepicker, to provide a date picker with a custom date format.

Here's an example of how you can achieve this:

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
    <label for="datepicker">Select a Date:</label>
    <input type="text" id="datepicker">

    <script>
        $(function() {
            $("#datepicker").datepicker({
                dateFormat: "dd M yy" // Set the custom date format
            });
        });
    </script>
</body>
</html>

In this example:

  • We include jQuery and jQuery UI Datepicker libraries.
  • We create an input field with the type "text."
  • We initialize the Datepicker on the input field and specify the dateFormat option as "dd M yy" to achieve the "01 Jan 2023" format.

By using this approach, you can allow users to select dates in the desired format.

To integrate the HTML and JavaScript code for the date input with the "01 Jan 2023" format into your main PHP file, you can follow these steps:

  1. Ensure that you have included the necessary jQuery and jQuery UI Datepicker libraries in your PHP file. You can include these lines in the <head> section of your PHP file:
<head>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
  1. Locate the part of your PHP code where you want to integrate the date input field with the "01 Jan 2023" format.

  2. Replace the existing date input HTML code (e.g., <input type="date" id="your-date-input">) with the following code:

<input type="text" id="datepicker">
  1. Below the input field, add the JavaScript code to initialize the Datepicker and specify the desired date format:
<script>
    $(function() {
        $("#datepicker").datepicker({
            dateFormat: "dd M yy" // Set the custom date format
        });
    });
</script>

Make sure that this JavaScript code is placed within a <script> block within the HTML section of your PHP file.

  1. Save the changes to your PHP file.

Now, when you load your PHP web page, the date input field will be displayed with the "01 Jan 2023" format, and users can select dates using the jQuery UI Datepicker.

momothefox avatar Sep 08 '23 15:09 momothefox