php - Change date string from Dutch to English to use it in strtotime -


i have following dutch string date:

dinsdag, 18 april 2017 

now want strip day , month, , can following example, doesn't work because in dutch , strtotime works english strings.

$stripday = date('d',strtotime($date)); $stripmonth = date('m',strtotime($date)); 

so checked other options, , found strptime function states can work.

$format = '%l, %d %m %y'; setlocale(lc_time, 'nl_nl');     setlocale(lc_all, 'nl_nl'); 

first configured format, , set locale. if use following code still gives me 1's back.

$stripday = date('d',strptime($date)); $stripmonth = date('m',strptime($date)); 

can explain me doing wrong here?

you can define array contain english days , dutch day , can replace dutch string english string this:

<?php     function dutch_strtotime($datetime) {         $days = array(             "maandag"   => "monday",             "dinsdag"   => "tuesday",             "woensdag"  => "wednesday",             "donderdag" => "thursday",             "vrijdag"   => "friday",             "zaterdag"  => "saturday",             "zondag"    => "sunday"         );          $months = array(             "januari"   => "january",             "februari"  => "february",             "maart"     => "march",             "april"     => "april",             "mei"       => "may",             "juni"      => "june",             "juli"      => "july",             "augustus"  => "august",             "september" => "september",             "oktober"   => "october",             "november"  => "november",             "december"  => "december"         );          $array = explode(" ", $datetime);         $array[0] = $days[strtolower($array[0])];         $array[2] = $months[strtolower($array[2])];         return strtotime(implode(" ", $array));     }     $date = "woensdag 22 oktober 2014 08:41:42";     echo date("l d-m-y h:i:s", dutch_strtotime($date)) . "<br />";     echo date("d-m-y", dutch_strtotime($date)); ?> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -