Jump to content

[SOLVED] converting a date format (dd/mm/yyyy) into a time() format


Recommended Posts

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

 

$newDate = date("d/m/Y", $time);

 

my mistake you wanted it the other way. I think this is what you want:

 

http://us2.php.net/manual/en/function.strtotime.php

Does anyone have anymore knowledge on this because I have explored the function mentioned above but I have on problem.

 

According to the manual it will convert any english date into a time() type format. but thats not quite true.

In england dd/mm/yyyy is standard but if you put in a date that is formatted like that it assumes it is mm/dd/yyyy which is the american format.

Is their anyway I can tell strtotime() that its dd/mm/yyyy instead of mm/dd/yyyy ??

 

thanks in advance

If you explode the date you can use the mktime() function.

 

http://us2.php.net/mktime

 

//int mktime ( [int $hour [, int $minute [, int $second [, int $month [, int $day [, int $year [, int $is_dst]]]]]]] )
list($day,$month,$year) = explode("/", $date);

$unixTime = mktime(0,0,0,$month,$day,$year);

  • 1 year later...

i just thought I would mention that another thing you could do is parse the date into an array using the date_parse() method.

 

I was looking for a way to reformat a MYSQL timestamp string and this (date_parse($row["date"]);) worked perfectly.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.