Jump to content

Date Conversion Issues

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Drew

Drew

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
hi all,

This may seem dumb but I am having a little issue that I have been attempting to cure but no command I use has any affect, even though it should work as far as I have read and seen.

I'm trying to convert using JavaScript from a DateTime to an EPOCH time. But I am unable to do to.

I have the date in the format "d/m/Y H:i:s" example: "28/04/2010 18:34:56"

I'm trying to turn that into the EPOCH equivalent. I can easily convert back, because that's all being done using PHP, I'm not that good with JavaScript and would like some assistance in this matter. I've tried many possibilities and alterations, but it doesn't seem to work.

Can anyone help please?

#2
bmett

bmett

    Newbie

  • Members
  • PipPip
  • 12 posts
Hi there,

I'm pretty sure PHP can do this for you.

Have a look at this part of the PHP Manual: DateTime::createFromFormat

Hope that helps,

Cheers,
Bjorn

#3
Drew

Drew

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
hi bmett,

Yes, I do understand that PHP can achieve this, but I'm NEEDing it in Javascript because I'm using an AJAX request and I need someone that knows javascript to be able to tell me how I can do the javascript conversion so that I am able to hold onto a date field and move it to another field without replacing the field with a brand new date.

On the AJAX request I have one piece of javascript that runs and puts a the date into the field, but the date is in the wrong format so it can't enter into the database.

I know PHP very very well, and it can't do what I'm attempting to do.

If you know how to convert EPOCH into standard Australian time, then I would love to know. I've looked many paces and just can'tfind what I'm looking for. They always create a new DATETIMESTAMP instead of using an old one, and this is what I want to do. Just put the time from the submitted form into a feild on the existing form without submitting the form and sending the data to the database.

I know I'm picky about what I want. I know this is the javascript forum, NOT the AJAX forum, but I'm needing elp with JAVASCRIPT, NOT AJAX. Just in case people misunderstand. Since AJAX IS JAVASCRIPT. But my request is regarding JavaScript, not AJAX. Say it enough times and it sounds boring... lol...

Look forward to hearing from someone in ANOTHER few weeks.

I appreciate that you tried bmett. Thanks.