Jump to content

A few Extremely Simple Questions


Branman

Recommended Posts

Hello everyone,

 

My name is Brandon and I'm fairly new to php. I just had some questions...

 

In the database I am using the premium subscription END date is stored as a unix time stamp. however when I go to see it I get a date back from 1969..:

 

its a simple date convert script

Link to comment
Share on other sites

you can do it 2 ways, using mysql or using php to convert the timestamp

 

mysql

$sql = "SELECT FROM_UNIXTIME(`fieldname`,'%Y %D %M %h:%i:%s %x') AS newdate FROM tablename";

 

Now newdate will be your formatted date

 

php

<?php
$sql = "SELECT * FROM tablename";
$res = mysql_query($sql) or die(mysql_error());
while($r = mysql_fetch_array($res)){
$newdate = date("Y-m-d G:i:s", $r['timestamp']);
} 
?>

 

Ray

Link to comment
Share on other sites

Well, as you can tell I am extremely nooblety at this. Here is what I have:

Current Code:

[code=php:0]$sql = mysql_query("SELECT * FROM ibf_subscription_trans WHERE id=". $_COOKIE['member_id']);
while ($r = mysql_fetch_array($sql))
{
$newdate = date("Y-m-d G:i:s", $r['subtrans_end_date']);
echo "$newdate";
} 

 

Timestamp information:

 

Table Name: ibf_subscription_trans

Field Name: subtrans_end_date

 

All I want to display is - the end date =/ The code above did not work.

Link to comment
Share on other sites

1202336734 <- That's one of them.

 

If you are storing them in that format (UNIX timestamp), you can just remove the strtotime() call within the date function. I was assuming by your column name that you were using the MySQL DATETIME data type rather than storing it as an integer.

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.