Date format question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hann...
Forum Newbie
Posts: 1
Joined: Wed Jun 03, 2009 3:29 am

Date format question

Post by hann... »

hi,

I've got a problem regarding a dateformat, and I'm hoping you can help me.
I'm using a great JQuery datepicker script, and I've managed to get the data into my php script, where I want to use it (e.g. store it in the database) but I've got no idea what kind of dateformat it is. I need to get the day, month and year from the datepicker.

when I select a date, the corresponding output is, for example, "Wed Jun 17 2009 00:00:00 GMT+0200 (CEST)". but when all the selected dates are put in an array by the datepicker the output I get is 1245189600000.

I can't find any corresponding numbers in there, does anyone know how to 'unscramble' this?

I've got some more examples for you:
Thu Jun 04 2009 00:00:00 GMT+0200 (CEST) -> 1244066400000
Sat Oct 10 2009 00:00:00 GMT+0200 (CEST) -> 1255125600000
Sun Jan 16 2011 00:00:00 GMT+0100 (CET) -> 1295132400000

I'm really hoping you can help me! thanks in advance,
Hanneke
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: Date format question

Post by mattpointblank »

That looks like the output of php's strtotime() function, which turns a string like "14th March 2009" into a single number (it's actually the number of seconds since 1st January 1970).

You could use php's date formatting syntax to produce a custom date like this:

Code: Select all

 
$newdate = date("Y-m-d g:i:a", "1245189600000");
 
Try it!
Post Reply