Welcome Guest, Not a member yet? Register   Sign In
Date problems
#1

[eluser]Rubiz'[/eluser]
Hi... when I try to make a date, I have a value $date = 2008-3-16, I do this: date('d.m', $date); I have this return error:
Code:
A PHP Error was encountered

Severity: Notice

Message: A non well formed numeric value encountered

Filename: views/home.php

Line Number: 48

Anyone know why?
#2

[eluser]Matthew Lanham[/eluser]
the second parameter of the date function needs to be a timestamp...

Therefore you could either use something like mktime() or if you want to convert from US to UK do a simple explode() then re-orginise the parts
#3

[eluser]Rubiz'[/eluser]
Well, I made a explode, but I think this is not a expert pratice... advanced programmers use that?
Thanx Swanweb for the answer Smile
#4

[eluser]Glen Swinfield[/eluser]
In the example you have given you could use:

date('d.m',strtotime($date));
#5

[eluser]Matthew Lanham[/eluser]
@Rubiz : yea explode is used a lot, it's fast and only needs a small amount of code...the functions would not be available if they were not used Tongue




Theme © iAndrew 2016 - Forum software by © MyBB