3

I am working on a simple date picker which show todays date as a default. The problem is that I cant make it work same on different browsers as Chrome, firefox and Opera.

<?php
  $timezone = "Europe/Oslo";
  date_default_timezone_set($timezone);
  $today = date("d.m.Y");
echo $today." <br>";
?>

<html>
  <body>
    <input type="date" value="<?php echo $today ?>">
  </body>
</html>

Google Chrome:

enter image description here

Firefox:

enter image description here

Opera:

enter image description here

As you can see in firefox i get the date, but not in GC or Opera.

But when I format the date as: $today = date("Y-m-d");

It looks like this in Google Chrome:

enter image description here

Opera:

enter image description here

Firefox:

enter image description here

2 Answers 2

1

input type="date" is not supported in firefox so it takes the value just as a text and in chrome default format is dd/mm/yyyy

in opera default format is mm/dd/yyyy

if you just want to display the date change the type to text will support any format

<input type="text" value="<?php echo $today ?>">
Sign up to request clarification or add additional context in comments.

2 Comments

With that, it will lose this possibily to be a datepicker: i.imgur.com/HJBPmlo.png
ok.. but it ( date type ) will not support in browsers like firefox and IE ,check jquery datepicker it will support all formats and will suport in all browsers jqueryui.com/datepicker
0

The date type is not yet supported by FireFox.

For Chrome and Opera, you can format like this:

$ today = date ("Y-m-d");

To determine the browser and adjust your display you can use this method

You can also use a date picker js such as JQuery

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.