Viewed   117 times

I am working on a php code $formated_date_new = date('M d, Y',strtotime($this_date)); which gives me the month name in english.

<script>
       document.getElementById('title_en').value = "<?php echo $formated_date_new ?>";
</script>

The above script returns the date in the following format (with month name in english) :

Mar 13, 2019 

For getting the month name in french, I need to integrate the following code but I am not sure how to do it.

<?php
setlocale(LC_TIME, "fr_FR");
echo strftime(" in French %d.%M.%Y and");


The o/p which I want is:

13 mars 2019

 Answers

1

Use strftime instead of date:

setlocale( LC_TIME, "fr_FR" );
$formated_date_new = strftime( "%d %b %Y", strtotime( $this_date ) );

strftime refernce:

http://php.net/manual/en/function.strftime.php

Monday, December 26, 2022
2

You are probably using a windows machine which has different language codes in PHP than a Unix based one.

Try:

setlocale(LC_TIME, 'de_DE', 'deu_deu');

This will first try to set it to 'de_DE' (Linux/Unix) and have the 'deu_deu' code as a fallback for windows (PHP Version >= 4.3).

Example in the german PHP documentation

Wednesday, November 9, 2022
 
4

date() and DateTime do not respect locale

use strftime()

http://php.net/manual/en/function.strftime.php

http://php.net/manual/en/function.date.php

To format dates in other languages, you should use the setlocale() and strftime() functions instead of date().

Friday, December 23, 2022
5

You are correctly using the password_verify() function as long as $row['password'] is returning the correspondent password hash created by password_hash() of the plain password, and not the plain password itself or any other value than that.

Note that no further security concerns are included in this answer.

Wednesday, December 14, 2022
3

When PHP 7 comes out, it has a new function called random_int() that serves this purpose.

If you need this today (i.e. in a PHP 5 project), check out random_compat.

At the very least, look at how random_int() is implemented in random_compat. Among other reasons, it still works for ranges larger than PHP_INT_MAX. (Yes, it uses /dev/urandom.)

Demo: http://3v4l.org/VJGCb

Monday, December 5, 2022
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :