Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3751400
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:04:08+00:00 2026-05-19T09:04:08+00:00

I have some code (it’s part of a wordpress plugin) which takes a text

  • 0

I have some code (it’s part of a wordpress plugin) which takes a text string, and the format specifier given to date(), and attempts to parse it into an array containing hour, minute, second, day, month, year.

Currently, I use the following code (note that strtotime is horribly unreliable with things like 01/02/03)

// $format contains the string originally given to date(), and $content is the rendered string
if (function_exists('date_parse_from_format')) {
    $content_parsed = date_parse_from_format($format, $content);
} else {
    $content = preg_replace("([0-9]st|nd|rd|th)","\\1",$content);
    $content_parsed = strptime($content, dateFormatToStrftime($format));
    $content_parsed['hour']=$content_parsed['tm_hour'];
    $content_parsed['minute']=$content_parsed['tm_min'];
    $content_parsed['day']=$content_parsed['tm_mday'];
    $content_parsed['month']=$content_parsed['tm_mon'] + 1;
    $content_parsed['year']=$content_parsed['tm_year'] + 1900;
}

This actually works fairly well, and seems to handle every combination I’ve thrown at it.

However, recently someone gave me 24 Ноябрь, 2010. This is Russian for November 24, 2010 [the date format was j F, Y], and it is parsed as year = 2010, month = null, day = 24.

Are there any functions that I can use that know how to translate both November and Ноябрь into 11?

EDIT:

Running print_r(setlocale(LC_ALL, 0)); returns C. Switching back to strptime() seems to fix the problem, but the docs warn:

Internally, this function calls the strptime() function provided by the system’s C library. This function can exhibit noticeably different behaviour across different operating systems. The use of date_parse_from_format(), which does not suffer from these issues, is recommended on PHP 5.3.0 and later.

Is date_parse_from_format() the correct API, and if so, how do I get it to recognize the language?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:04:09+00:00Added an answer on May 19, 2026 at 9:04 am

    Try to set the locale to Russian as hinted in the manual:

    Month and weekday names and other language dependent strings respect the current locale set with setlocale() (LC_TIME).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that tries to parse a date string. When I do
I have some code which collects points (consed integers) from a loop which looks
I have some code in an IAuthorizationFilter which redirects the user to a login
I have some code which utilizes parameterized queries to prevent against injection, but I
I have some code which I am making available via RMI. If my program
I have some code, which was written couple of years ago and works only
I have some code which detects when properties are changed on objects, which are
I have some code acting as an HTTP client which supports basic authentication as
I have some code which needs to do things based on a schedule: e.g.
I have some code for starting a thread on the .NET CF 2.0: ThreadStart

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.