Jump to content

Recommended Posts

Ok so Ive have never used the date() function before untill now. I thought I had it all down (simple it seemed) but some how I getting something weird.

[code]$signupdate = date("F d Y" , $row["signupdate"]);
$lastlogin = date("F d Y" , $row["lastlogin"]);[/code]

The $row["signupdate"] and $row["lastlogin"] are from a MySQL query and it out put something like this normally: 2006-07-12 23:28:57.

But when I load the page it comes out as: December 31 1969. ???? Why, what, no! Any ideas?
Link to comment
https://forums.phpfreaks.com/topic/14626-wierd-date-output/
Share on other sites

The date() function is expecting a UNIX timestamp as the second parameter, not a string. A UNIX timestamp is the number of seconds since 1-1-1970 for the date. To get this number you can use the strtotime() function. So in your case:
[code]<?php
$signupdate = date("F d Y" , strtotime($row["signupdate"]));
$lastlogin = date("F d Y" , strtotime($row["lastlogin"]));
?>[/code]

Ken
Link to comment
https://forums.phpfreaks.com/topic/14626-wierd-date-output/#findComment-58198
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.