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 6845125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:27:43+00:00 2026-05-27T00:27:43+00:00

I’m trying to convert the string 11/24/2011 @ 01:15pm to a UNIX timestamp. The

  • 0

I’m trying to convert the string 11/24/2011 @ 01:15pm to a UNIX timestamp. The format is m-d-Y @ h:ia

I can’t seem to get strtotime to work with the string. Is there a way to reverse the data function? Is my only choice to create a new non-default php function to convert the string?

The server is running CentOS 5, Apache 2.2 and PHP 5.2.17.

  • 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-27T00:27:43+00:00Added an answer on May 27, 2026 at 12:27 am

    Under PHP 5.2, you can use strptime to parse a date-time string with a specific format, then use mktime to convert the result to a timestamp.

    $timeString = '11/24/2011 @ 01:15pm';
    
    $timeArray = strptime($timeString, '%m/%d/%Y @ %I:%M%p');
    $timestamp = mktime(
        $timeArray['tm_hour'], $timeArray['tm_min'], $timeArray['tm_sec'], 
        $timeArray['tm_mon']+1, $timeArray['tm_mday'], $timeArray['tm_year']+1900
    );
    

    This should be abstracted as a function, possibly two:

    function strptimestamp($date, $fmt) {
        $timeArray = strptime($date, $fmt);
        return mktime(
            $timeArray['tm_hour'], $timeArray['tm_min'], $timeArray['tm_sec'], 
            $timeArray['tm_mon']+1, $timeArray['tm_mday'], $timeArray['tm_year']+1900
        );
    }
    
    function strpmy($date) {
        return strptimestamp($date, '%m/%d/%Y @ %I:%M%p');
    }
    

    Support for parsing the period abbreviation appears to vary from OS to OS. If the above doesn’t work on a particular OS, try “%P” instead of “%p” or pass the time string through strtoupper (or both). The following should work under any OS, though it’s preferable to get strptime to handle the entirety of the parsing, as the following is less suitable as the basis for a generic strptimestamp function.

    static $pm_abbrevs = array('pm' => 1, 'p.m.' => 1, 'µµ' => 1, 'µ.µ.' => 1);
    $timeString = '11/24/2011 @ 01:15pm';
    
    $timeArray = strptime($timeString, '%m/%d/%Y @ %I:%M');
    $period = strtolower($timeArray['unparsed']);
    if (isset($pm_abbrevs[$period])) {
        $timeArray['tm_hour'] += 12; 
    }
    $timestamp = mktime(
        $timeArray['tm_hour'], $timeArray['tm_min'], $timeArray['tm_sec'], 
        $timeArray['tm_mon']+1, $timeArray['tm_mday'], $timeArray['tm_year']+1900
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.