Jump to content

[SOLVED] Translating DATETIME into TIMESTAMP


woolyg

Recommended Posts

Hi all,

 

Safe in the knowledge that TIMESTAMP format is DATETIME's ugly older sister, if I have a DATETIME string (2007-10-25 02:42:52) that I need to switch to TIMESTAMP.

 

Maybe I'm into ugly old chicks, who knows.

Can anyone help?

 

Cheers,

WoolyG

 

Link to comment
Share on other sites

Is there a way to do it in PHP? I just need to run a quick function using TIMESTAMP as opposed to DATETIME..

 

I'm not positive I follow, but if you're simply trying to translate a DATETIME into a unix timestamp, just use strtotime():

<?php
$dt = '2007-10-04 00:00:00';
$ts = strtotime($dt);
if ($ts !== FALSE)
{
  // Success!
  echo "Timestamp = {$ts}";
}
?>

Link to comment
Share on other sites

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.